On 2016-09-20 11:48, Gabriele Brambilla wrote:
> does it mean that my number of points is too high?

In short, yes. From your usage of the 'print' statement, you are running
the code under Python 2.x. In this version of Python, the 'range'
function creates a full list of numbers, and so you are asking 'range'
to create a list of 33.8 billion integers. Python lists are essentially
implemented in C as dense arrays of pointers to PyObject structs, so in
addition to the actual numeric values, you will need eight bytes per
value in the list (assuming a 64-bit OS and Python build). This is
already 270GB of memory just for these pointers, in addition to the
actual numeric values, which might take up to an additional 135GB (if
each numeric value is stored as a 32-bit integer). Are you running this
on a machine with ≥405GB memory?

To solve your immediate problem, you could replace 'range' with 'xrange'
in your code, but this will probably only allow you to encounter another
problem: this loop will take a *very* long time to run, even without
doing any numerical work inside it. Unfortunately, there's no way to
suggest any algorithm/numerical analysis improvements without more
information about what you're trying to accomplish.

Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:

Reply via email to