Message22708
Logged In: YES
user_id=31435
range() constructs a list. The list takes 4 bytes/entry, so
you get about 40MB reclaimed when the list goes away. The
space for integer objects happens to be immortal, though,
and the approximately 12 bytes per integer doesn't go away.
Space for floats is also immortal, BTW.
There aren't easy resolutions. For example, the caching of
space for integer objects in a dedicated internal int freelist
speeds many programs. And if Python didn't do special
memory allocation for ints, malloc overhead would probably
boost the memory burden in your example to 16 bytes/int.
So there are tradeoffs. Note that xrange() can usually be
used instead to create one integer at a time (instead of
creating 10 million simultaneously). Then the memory burden
is trivial. |
|
| Date |
User |
Action |
Args |
| 2007-08-23 14:26:43 | admin | link | issue1048495 messages |
| 2007-08-23 14:26:43 | admin | create | |
|