Hi Guido,

It's great to hear from you directly :)

Sorry for not mentioning this earlier. The use case here is profiling.
Specifically, Scalene: https://github.com/emeryberger/scalene.

At the moment, Scalene does stack inspection to decide if an allocation is
from the user. If there are hooks helping with the differentiation, it's
arguably more efficient. Additionally, users might want to know about
memory allocated explicitly by their objects instead of by the interpreter
internals.

If the interpreter doesn't have this functionality already, it would
probably be difficult to add, as the existing allocation API is called
throughout the interpreter code base.

Thanks

On Sun, Jul 19, 2020 at 10:39 PM Guido van Rossum <gu...@python.org> wrote:

> What purpose do you have in mind for making this distinction? Even if it
> could be done easily (which I doubt), why would this be useful?
>
> On Sun, Jul 19, 2020 at 19:01 <wenjunhu...@umass.edu> wrote:
>
>> Hello,
>>
>> The API provided by PEP 445 makes it possible to intercept allocation
>> requests through hooks, but it seems that both user allocations and
>> interpreter allocations are sent to the hooks.
>>
>> Here, user allocations refer to those that are triggered explicitly by
>> the code (e.g. memory allocations to hold the integer created by x = 1),
>> and interpreter allocations refer to everything else (e.g. memory
>> allocations for internal states).
>>
>> I've poked around a bit in the interpreter source code, and I think such
>> differentiations aren't being done at all, so all allocations are directed
>> to the same set of API. If that's indeed the case, why is the interpreter
>> implemented this way? Would it make sense to implement the differentiation?
>>
>> Thanks
>> _______________________________________________
>> Python-ideas mailing list -- python-ideas@python.org
>> To unsubscribe send an email to python-ideas-le...@python.org
>> https://mail.python.org/mailman3/lists/python-ideas.python.org/
>> Message archived at
>> https://mail.python.org/archives/list/python-ideas@python.org/message/HJQW2MWFP5AUWTRD5N2TVQWAIKIDFNJW/
>> Code of Conduct: http://python.org/psf/codeofconduct/
>>
> --
> --Guido (mobile)
>
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/H33JNM67O3OYAGOLCDHURPFT6IDAU4ZH/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to