Qualcuno sa come Python gestisce internamente i tipi int e long?
- Sceglie il tipo giusto dinamicamente?
- Qual è il limite per un int?
- Sto usando Python 2.6, è diverso con le versioni precedenti?
Come devo capire il codice qui sotto?
>>> print type(65535)
<type 'int'>
>>> print type(65536*65536)
<type 'long'>
Aggiornare:
>>> print type(0x7fffffff)
<type 'int'>
>>> print type(0x80000000)
<type 'long'>
reallocva tutto bene. Ma non ne sono del tutto sicuro, quindi lascerò la risposta a qualcun altro.
var = 666L
intè un C long(il default è firmato) ... vedi <CPython 2.X source>/Include/intobject.h: typedef struct {PyObject_HEAD long ob_ival; } PyIntObject; In ogni caso Python 2.x intammette numeri negativi; una C unsignedsemplicemente non ce la farebbe.