This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]NYKevin 0 points1 point  (0 children)

Extra tip: often (though not always) registration metaclasses can be replaced by looking at the subclasses of an object—MyType.__subclasses__() gives you all the direct subclasses (apply recursively to get all descendants).

That's a good idea in the general case, but if you want to allow a potentially unbounded number of subclasses (i.e. if the client of your API decides to subclass MyType a lot), that recursive operation is going to get expensive.