By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,050 Members | 1,019 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,050 IT Pros & Developers. It's quick & easy.

array of 64-bit ints?

P: n/a
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.

Thanks,
Steve Vavasis, va*****@math.uwaterloo.ca
Jun 27 '08 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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.

Regards,
Martin
Jun 27 '08 #2

P: n/a
Martin v. L?wis <ma****@v.loewis.dewrote:
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 <ni**@craig-wood.com-- http://www.craig-wood.com/nick
Jun 27 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.