Logged In: YES
user_id=86307
Here's my use case. I've been experimenting with the
multimethods module written by David Mertz (part of his
gnosis utilities). This uses mros from a declared signature
and from the actual parameter types to determine which
overload to call. Classic classes don't have an mro, so I
needed to calculate one to accomodate them. Having done so,
I wanted to cache it. The best solution might be the one
I'm using now, which is simply to assign the calculated mro
to a __mro__ attribute of the classic class. However, it
seemed better to me to use an external cache, rather than
modifying the class. I wanted this external cache to be a
WeakKeyDictionary, because, if a module containing a classic
class is reloaded, I didn't want the old version of the
class kept alive solely by my cache (it avoided a reference
cycle with the mro itself by storing a list with the first
element set to None; then, when fetched, copying the list
and putting the class in the copy's first element).
Anyway, feel free to reject this. It was so easy to do, I
just thought I'd go ahead and post it in case the lack was
simply an oversight.
|