A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2016-September/146141.html below:

[Python-Dev] Tweak to PEP 523 for storing a tuple in co_extra

[Python-Dev] Tweak to PEP 523 for storing a tuple in co_extraChris Angelico rosuav at gmail.com
Sat Sep 3 19:13:05 EDT 2016
On Sun, Sep 4, 2016 at 8:03 AM, Yury Selivanov <yselivanov.ml at gmail.com> wrote:
> On 2016-09-03 12:27 PM, Brett Cannon wrote:
>>
>> Below is the `co_extra` section of PEP 523 with the update saying that
>> users are expected to put a tuple in the field for easier simultaneous use
>> of the field.
>>
>> Since the `co_extra` discussions do not affect CPython itself I'm planning
>> on landing the changes stemming from the PEP probably on Monday.
>
>
> Tuples are immutable.  If you have multiple co_extra users then they will
> have to either mutate tuple (which isn't always possible, for instance, you
> can't increase size), or to replace it with another tuple.

Replace it, but only as they register themselves with a particular
function. Imagine a profiler doing something vaguely like this:

class FunctionStats:
    def __init__(self):
        self.info = [whatever, whatever, blah blah]

def profile(func):
    """Decorator to mark a function for profiling"""
    func.__code__.co_extra += (FunctionStats(),)
    return func

Tuple immutability impacts the initialization only. After that, you
just iterate over it.

ChrisA
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4