首页 > 解决方案 > 当需要 long/bigints 时强制 python 失败

问题描述

有没有办法在程序中禁止这些?

例如:

x = 2**50 # expected to work (in a 64 bit binary)

x = x * x # expected to fail/raise

原因:bigint 操作比 int 慢得多,但是 python 从一个切换到另一个没有警告。我想知道这样我就可以专注于优化工作。

我对 python 2.7(特别是 pypy)感兴趣。我知道在 python 3 中对 long 的处理是不同的。

标签: python

解决方案


推荐阅读