[Python-ideas] Preallocated tuples and dicts for function calls
Serhiy Storchaka
storchaka at gmail.com
Sat Mar 9 04:18:49 EST 2019
09.03.19 03:02, Greg Ewing пише:
> Martin Bammer wrote:
>
>> what about the idea that the interpreter preallocates and
>> preinitializes the tuples and dicts for function calls where possible
>> when loading a module?
>
> This would not be thread-safe. Locking would be needed around uses
> of the preallocated objects, and that might take away some or all
> of the gain. It would also introduce unexpected interactions
> between threads.
Thread safety is not a problem (because of GIL). The problems are the
reentrancy, functions which save references to args and kwargs, and the
garbage collector.
More information about the Python-ideas
mailing list