But it doesn’t compare against doing something like this does, where you define a (parametric) class inside a function and then return the new class that was created. Is that because you don’t consider that programmatic class creation?
In any case, I’d be curious to hear what you think about how this approach compares to using
One downside of
types.new_type() is that it requires Python 3.3+. I guess the Python 3 Cookbook assumes that too, but for a library like bidict that still maintains Python 2 compatibility, it’s unfortunately not an option.