array of 64-bit ints?
Nick Craig-Wood
nick at craig-wood.com
Fri May 23 16:30:09 EDT 2008
Martin v. L?wis <martin at v.loewis.de> wrote:
> > Is it possible to have an array of 64-bit-ints using the standard Python
> > array module? On my 64-bit architecture (AMD64, MSVC), both "int" and
> > "long int" are 32 bit integers. To declare 64-bit ints, one needs either
> > "long long int" or "size_t". However, according to the Python array
> > documentation, arrays of "size_t" or "long long int" are not available.
>
> No, it's not possible.
You could do it with ctypes like this...
from ctypes import *
Array = c_int64 * 100
a = Array()
for i in range(100):
a[i] = 2**63 - i
for i in range(100):
print a[i]
prints
-9223372036854775808
9223372036854775807
9223372036854775806
[snip]
9223372036854775710
9223372036854775709
ctypes arrays are fixed length once created though.
--
Nick Craig-Wood <nick at craig-wood.com> -- http://www.craig-wood.com/nick
More information about the Python-list
mailing list