python newbie - slicing a big memory chunk without GC penalties
Alex Martelli
aleax at aleax.it
Sun Feb 2 14:58:07 EST 2003
Giovanni Bajo wrote:
> Hello,
>
> Sorry if the question is trivial, but I am a newbie with Python. I have a
> file read into memory within a 'sequence' (or whatever is returned by
> file.read()), and I need to process it 512 bytes a time. Now, I was doing
If you can use standard library module mmap instead of file,read, it
is quite possible that your performance can increase, most particularly
given a usage pattern such as:
> something like:
>
> for i in range(0, len(buf)/512):
> Process(buf[i*512 : (i+1)*512])
Alex
More information about the Python-list
mailing list