STINNER Victor added the comment:
> I agree with Josh, PyTuple_New() can be faster than PyMem_Malloc() due to
> tuple free list.
According to benchmarks, PyTuple_New() is slower than PyMem_Malloc(). It's not
surprising for me, using a tuple object requires extra work:
* Track and then untrack the object from the garbage collector
* Destructor uses Py_TRASHCAN_SAFE_BEGIN/Py_TRASHCAN_SAFE_END macros
* Some additional indirectons
When I started working on "fastcall", I was surprised that not creating tuples
has a *significant* (positive) effect on performance. It seems to be between 5%
and 45% faster. Obviously, it depends on the speed of the function body. The
speedup is higher for faster functions, like fast functions implemented in C.
Python tracker <rep...@bugs.python.org>
Python-bugs-list mailing list