[Python-ideas] PEP 550 v2

Antoine Pitrou antoine at python.org
Wed Aug 16 16:12:22 EDT 2017



Hi,

> * ``sys.get_execution_context()`` function.  The function returns a
>   copy of the current EC: an ``ExecutionContext`` instance.

Can you explain the requirement for it being a copy?  What do you call a
copy exactly?  Does it shallow-copy the stack or does it deep copy the
context items?

> * ``uint64_t PyThreadState->unique_id``: a globally unique
>   thread state identifier (we can add a counter to
>   ``PyInterpreterState`` and increment it when a new thread state is
>   created.)

How does this interact with sub-interpreters? (same question for rest of
the PEP :-))

> * O(N) for ``sys.get_execution_context()``, where ``N`` is the
>   total number of items in the current **execution** context.

Right... but if this is a simple list copy, we are talking about an
extremely fast O(N):

>>> l = [None] * 1000
>>> %timeit l.copy()
3.76 µs ± 17.5 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)

(what is "number of items"? number of local contexts? number of
individual context items?)

> We believe that approach #3 enables an efficient and complete Execution
Context implementation, with excellent runtime performance.

What about the maintenance and debugging cost, though?

> Immutable mappings implemented with HAMT have O(log32N) performance
for both set(), get(), and merge() operations, which is essentially O(1)
for relatively small mappings

But, for relatively small mappings, regular dicts would also be fast
enough, right?

It would be helpful for the PEP to estimate reasonable parameter sizes:
- reasonable number of context items in a local context
- reasonable number of local contexts in an execution stack

Regards

Antoine.



More information about the Python-ideas mailing list