[Python-Dev] PEP 562

Ivan Levkivskyi levkivskyi at gmail.com
Wed Nov 15 05:53:19 EST 2017


On 15 November 2017 at 08:43, Serhiy Storchaka <storchaka at gmail.com> wrote:

> 14.11.17 22:34, Ivan Levkivskyi пише:
>
>> This function will be called only if ``name`` is not found in the module
>> through the normal attribute lookup.
>>
>
> It is worth to mention that using name as a module global will bypass
> __getattr__. And this is intentional, otherwise calling __getattr__ for
> builtins will harm a performance.
>
>
Good point!


> Backwards compatibility and impact on performance
>> =================================================
>>
>
> What is affect on pydoc, word completion, inspect, pkgutil, unittest?
>
>
This is rather gray area. I am not sure that we need to update them in any
way, just the people who use __getattr__ should be aware that
some tools might not yet expect it. I will add a note to the PEP about this.


>    def keep_pickleable(func):
>>        func.__name__ = func.__name__.replace('_deprecated_', '')
>>        func.__qualname__ = func.__qualname__.replace('_deprecated_', '')
>>        return func
>>
>>    @keep_pickleable
>>    def _deprecated_old_function(arg, other):
>>        ...
>>
>
> I would create more standard helpers (for deprecation, for lazy
> importing). This feature is helpful not by itself, but because it will be
> used for implementing new features. Using __getattr__ directly will need to
> write a boilerplate code. Maybe when implementing these helper you will
> discover that this PEP needs some additions.
>
>
>
But in which module these helpers should live?

--
Ivan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20171115/2744d828/attachment.html>


More information about the Python-Dev mailing list