Fast pythonic way to process a huge integer list

Cameron Simpson cs at zip.com.au
Wed Jan 6 22:31:56 EST 2016


On 06Jan2016 18:36, high5storage at gmail.com <high5storage at gmail.com> wrote:
>I have a list of 163.840 integers. What is a fast & pythonic way to process 
>this list in 1,280 chunks of 128 integers?

The depends. When you say "list", is it already a _python_ list? Or do you just 
mean that the intergers are in a file or something?

If they're already in a python list you can probably just use a range:

  for offset in range(0, 163840, 128):
    ... do stuff with the elements starting at offset ...

Cheers,
Cameron Simpson <cs at zip.com.au>



More information about the Python-list mailing list