A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2008-February/076804.html below:

[Python-Dev] int/float freelists vs pymalloc

[Python-Dev] int/float freelists vs pymallocChristian Heimes lists at cheimes.de
Mon Feb 11 02:38:09 CET 2008
I've done my own profiling with a different script. I was able to verify
Andrews results. The pymalloc approach makes int creation slightly
slower and has almost no effect on floats.

The creation of 1000 times a list of 1000 ints (range(1000)) is about
20msec slower. It almost doubles the time for a trivial test "for i in
range(1000): range(1000)" but that's an artificial test.


Current allocation schema
-------------------------

for i in range(1000): [float(x) for x in range(1000)]
10 loops, best of 3: 760 msec per loop

for i in range(1000): range(1000)
10 loops, best of 3: 27 msec per loop

for i in range(1000): [x for x in range(1000)]"
10 loops, best of 3: 218 msec per loop


Without a free list
-------------------

for i in range(1000): [float(x) for x in range(1000)]
10 loops, best of 3: 792 msec per loop

for i in range(1000): range(1000)"
10 loops, best of 3: 51.5 msec per loop

for i in range(1000): [x for x in range(1000)]
10 loops, best of 3: 241 msec per loop


With a fixed free list of 2,500 objects each
--------------------------------------------

for i in range(1000): [float(x) for x in range(1000)]"
10 loops, best of 3: 736 msec per loop

for i in range(1000): range(1000)"
10 loops, best of 3: 25 msec per loop

for i in range(1000): [x for x in range(1000)]"
10 loops, best of 3: 198 msec per loop


As you can clearly see an approach with a small free list in a fixed
size array like static PyFloatObject *free_list[PyFloat_MAXFREELIST] is
even faster than block allocation. A small free list with 80 objects
each would speed up the creation of floats and ints a bit *and* result
in a quicker return of memory to the OS.

Christian

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4