[pypy-dev] Freelist in PyPy? Reuse short lived objects?
Carl Friedrich Bolz-Tereick
cfbolz at gmx.de
Fri Jan 15 01:44:01 EST 2021
This is not ready at all and I don't have enough time to work on it at the moment, *however*: I have a small prototype (on the branch map-improvements) that changes the instance layout in PyPy to store type-stable instances with several fields that contain ints or floats much more efficiently. It seems to give a 50% speedup on your micro benchmark, so that's promising. There's still a bug somewhere and it needs very careful investigation whether it costs too much on non-numerical programs, but potentially this is a good improvement.
Cython is not likely to help on PyPy, because the overhead of our C-API emulation is too high. A free list is also unfortunately not really workable for us, since our GC strategy is very different (we don't know when an object is freed).
On January 14, 2021 4:34:12 PM GMT+01:00, PIERRE AUGIER <pierre.augier at univ-grenoble-alpes.fr> wrote:
>I was still playing with the idea to speedup codes using small
>I wrote a Cython extension which defines a Point (3d) cdef class and a
>Points cdef class (a vector of points). Both classes contain a pointer
>towards a point_ C struct:
>ctypedef struct point_:
> float x, y, z
>Of course, any computation with Point objects with involved several
>very short lived objects and we really want to avoid all the associated
>In Cython, one can decorate a cdef class with `@cython.freelist(8)` to
>I try to add a bit of logic to avoid freeing and allocating the memory
>for the struct
>If I understand correctly, doing such things is possible in CPython
>because the method __dealloc__ is called as soon as the objects is not
>accessible from Python. Or we can use the fact that it's very fast to
>get the reference count of an instance. But I think it is not the case
>Is there an alternative strategy efficient with PyPy?
>pypy-dev mailing list
>pypy-dev at python.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the pypy-dev