有人知道Python如何在内部管理int和long类型吗?
- 它会动态选择合适的类型吗?
- 一个整数的限制是多少?
- 我正在使用Python 2.6,与以前的版本有所不同吗?
我应该如何理解以下代码?
>>> print type(65535)
<type 'int'>
>>> print type(65536*65536)
<type 'long'>更新:
>>> print type(0x7fffffff)
<type 'int'>
>>> print type(0x80000000)
<type 'long'>realloc可以了。但我不太确定,因此我会将答案留给其他人。
                var = 666L
                int是C long(默认为带符号)...参见<CPython 2.X source>/Include/intobject.h:typedef struct {PyObject_HEAD long ob_ival; } PyIntObject; 在任何情况下,Python 2.x都int允许使用负数;C unsigned不能应付。