[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: python, python-gtk and memory usage



On Wed, 30 May 2001, Torsten Landschoff wrote:

> >>> a = range(10000000)
> >>> a = None
> >>> a = range(10000000)
>
> memory usage of the python process goes up to 154MB after the first command,
> down to 116MB after the second (at which stage I thought the bug is in
> python) but up to 154MB after the third command again so it is reusing the
> involved memory it seems.

xrange ([start,] stop[, step])
     This function is very similar to range(), but returns an ``xrange
     object'' instead of a list. This is an opaque sequence type which yields
     the same values as the corresponding list, without actually storing them
     all simultaneously. The advantage of xrange() over range() is minimal
     (since xrange() still has to create the values when asked for them)
     except when a very large range is used on a memory-starved machine (e.g.
     MS-DOS) or when all of the range's elements are never used (e.g. when the
     loop is usually terminated with break).



Reply to: