How to use a contiguous memory location of n bytes in python

C

chachi

Hi,

I want to know how to instantiate a data structure which has n bytes
(given by me) and is internally stored in a contiguous fashion. I know
list is not implemented like this, so I am in a fix. There seems to be
a buffer object available, but haven't seen it being used anywhere.
Does anyone know how to use Buffer? Say I want to write some data onto
the buffer and then write the contents of the entire buffer to a file
(without making a new string, but lets first get the buffer issue out
of the way), how do I do it?



Thanks,
ssg
 
B

bearophileHUGS

chachi:
I want to know how to instantiate a data structure which has n bytes
(given by me) and is internally stored in a contiguous fashion.

array.array("B", ...) may be fit for you. You can also use a numpy
array of bytes.

Bye,
bearophile
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,999
Messages
2,570,243
Members
46,836
Latest member
login dogas

Latest Threads

Top