[IPython-dev] Metaclasses in traitlets and PEP 487

Martin Teichmann lkb.teichmann at gmail.com
Mon Feb 15 09:29:44 EST 2016

Hi Thomas,

> Just to check that I understand, if the PEP is accepted, we wouldn't add a
> utils.metaclass module to traitlets, but instead use the new SubclassInit
> class in the standard library, and an equivalent backport on PyPI for
> already released Python versions, right?

This is currently the point of discussion. My current assumption is that
larger projects (like IPython) will certainly want to maintain backwards
compatibility, and are typically hesitant to add new dependencies.

The backport on PyPI will just be one short file which tries to import the
new classes in the standard library, and will fall back to an own
One way would then be to add this PyPI package as a dependency to
IPython. Another way would be to simply add that simple file to IPython,
then we have either the backwards compatibility or the compatibility
with other projects (if we did find the standard library classes), but not

The best compromise is probably to put it into a library like six, so that
we have compatibility at least between projects using the same
compatibility library. IPython is not using six, so I just opted for putting
said one file into IPython.

You also mentioned situations in which you want to have compatibility
with C++ extension metaclasses. Those will only be compatible once
our new metaclass makes it into the interpreter proper. That will still
take some time, though.



More information about the IPython-dev mailing list