Navigation
Recherche
|
[$] Altering Python attribute handling for modules
mercredi 6 septembre 2023, 21:29 , par LWN.net
A recent discussion on the Python forum looked at a way to
protect module objects (and users) from mistaken attribute assignment and deletion. There are ways to get the same effect today, but the mechanism that would be used causes a performance penalty for an unrelated, and heavily used, action: attribute lookup on modules. Back in 2017, PEP 562 ('Module __getattr__ and __dir__') set the stage for adding magic methods to module objects; now a new proposal would extend that idea to add __setattr__() and __delattr__() to them.
https://lwn.net/Articles/943619/
|
56 sources (32 en français)
Date Actuelle
ven. 17 mai - 16:35 CEST
|