473,406 Members | 2,467 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

array of 64-bit ints?

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
2 4273
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: gil | last post by:
If I use a literal string: theArray = Array("66.134.63.152", "66.134.63.152", "24.15.41.147") the arguments "theArray" works fine in my function. If I build my array with a for next my...
10
by: Craig Keightley | last post by:
I have the following array: function showCPUs(){ //name brandID dualCore dualProcessor var cpuItem=; var cpuItem=; var cpuItem=; var cpuItem=; var cpuItem=; var cpuItem=; var cpuItem=;
2
by: Frank Pool | last post by:
Hi, I have on large threedimensional array int largeArray; In a particular function I only need a part of this array So I'm using a new variable and assign it the follwoing way: int...
2
by: Wendell Wilkie | last post by:
I am working with a 3rd party unmanaged dll, and I need to pass an array of char* as an argument. I can used fixed to get a single char* as follows: char buf = new char; fixed (char* p = buf)...
3
by: GrkEngineer | last post by:
I recently had to use someone's struct from a native app to receive data over Udp. The struct has a array member which looked like this: struct sensorHdr{ char sName; }; When I tried to make...
15
by: Geoff Cox | last post by:
Hello, Can I separately declare and initialize a string array? How and where would I do it in the code below? It was created using Visual C++ 2005 Express Beta 2 ... In C# I would have ...
9
by: vicky | last post by:
hi all! This is an interesting question asked in interview of HCL. Suppose a situation that u have a pointer to an array and u don't the size of array, so how could u find the size of array by...
18
tpgames
by: tpgames | last post by:
How do I get code to access the images at the URL given? I'd like the user to be able to select which theme of images they want to view then the script would randomly pick an image to show. ...
6
by: Active8 | last post by:
Hi: This prob "magically" stopped and I'm not sure if I can recreate it, but thought I'd share it and maybe learn something. #include "stdafx.h" #include <stdlib.h> #include <math.h>...
13
by: pereges | last post by:
I've an array : {100,20, -45 -345, -2 120, 64, 99, 20, 15, 0, 1, 25} I want to split it into two different arrays such that every number <= 50 goes into left array and every number 50 goes...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.