Article 6EGVT [$] Altering Python attribute handling for modules

[$] Altering Python attribute handling for modules

by
jake
from LWN.net on (#6EGVT)
A recent discussion on the Python forum looked at a way toprotect module objects (and users) from mistaken attribute assignment anddeletion. There are ways to get the same effect today, but the mechanism that would be used causes aperformance penalty for an unrelated, and heavily used, action: attributelookup on modules. Back in2017, PEP562 ("Module __getattr__and __dir__") set the stage for adding magic methods to module objects; nowa new proposal would extend that idea to add __setattr__() and__delattr__() to them.
External Content
Source RSS or Atom Feed
Feed Location http://lwn.net/headlines/rss
Feed Title LWN.net
Feed Link https://lwn.net/
Reply 0 comments