Inada Naoki <songofaca...@gmail.com> added the comment:

@Serhiy 

> Do you mean sharing values of co_code and co_lnotab between code objects of 
> the same module?

Yes.

> How much memory does this save (in absolute and relative value)?

Maybe 1~3%, but I am not sure. I am more interested in reducing number of 
objects, because it will reduce import time.
Additionally, co_code is used while executing code. Unlike other cold data 
(e.g. docstring, annotations), sharing co_code will improve CPU cache 
utilization.

> Which functions have the same co_code?

For example,

```
# logging/__init__.py

    @property
    def manager(self):
        return self.logger.manager
...
    @property
    def name(self):
        return self.logger.name
```

Such simple functions are very common in OO-style code.

@Mark Shannon

Sure.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue42217>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to