Hi,

I need to help to attempt to optimize my experimental CPython fork
which uses tagged pointers.

When I proposed my PEP 620 "Hide implementation details from the C
API", I was asked about a proof that the PEP unlocks real optimization
possibilities. So I wrote an implementation of tagged pointers:
https://github.com/vstinner/cpython/pull/6

The main benefit is the memory usage. For example, list(range(200))
uses 1656 bytes instead of 7262 (4x less memory).

Sadly, my current simple implementation is 1.1x slower than the
reference. I suspect that adding a condition to Py_INCREF() and
Py_DECREF() explains a large part of this overhead.

My implementation uses tagged pointers for:

* integers in the range: [-5; 256]
* None, True and False singletons

It would be nice to use tagged pointers for a wide range of integer
numbers, but I wrote a simple implementation: _Py_TAGPTR_UNBOX() has
to return a borrowed reference. This function should return a strong
reference to support a larger range.

More information in the document:
https://github.com/vstinner/cpython/blob/tagged_ptr/TAGGED_POINTERS.rst

Victor
-- 
Night gathers, and now my watch begins. It shall not end until my death.
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/4ETF7H5COIZWTCXDRTITVMU4P5DLRDLU/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to