[Python-Dev] PEP 487 vs 422 (dynamic class decoration) (original) (raw)

PJ Eby pje at telecommunity.com
Fri Apr 3 21:23:53 CEST 2015


On Fri, Apr 3, 2015 at 11:04 AM, Nick Coghlan <ncoghlan at gmail.com> wrote:

Extending the descriptor protocol to include a per-descriptor hook that's called at class definition time sounds like a potentially nice way to go to me. While you could still use it to arbitrarily mutate the class object, it's much clearer that's not the intended purpose, so I don't see it as a major problem.

Just to be clear, mutating the class object was never the point for my main use case that needs the PEP 422 feature; it was for method overloads that are called remotely and need to be registered elsewhere. For some of my other use cases, adding metadata to the class is a convenient way to do things, but classes are generally weak-referenceable so the add-on data can be (and often is) stored in a weak-key dictionary rather than placed directly on the class.



More information about the Python-Dev mailing list