Ivan Levkivskyi <levkivs...@gmail.com> added the comment:
Serhiy, thanks for benchmarks and good suggestions! > If make NewType a class, I would make the repr looking like a call This is a nice idea, it indeed looks better. We can probably also use `_type_repr()` helper for the argument (for consistency). > Should the NewType() result be pickleable? This is not required by PEP 484, but I could imagine this may be useful. > If it should be pickleable, should it be pickled by name (resulting in > restoring the same instance on unpickling, but failing if it is not > accessible by name) or by its arguments (resulting in creating a new instance > when unpickled)? Logically, they should behave like class objects, so if we are going to make them pickleable, they should be pickled by full name. > Should it support comparison and what values should be treated as equal? Again, since they should behave like class objects, I think we don't need any dedicated `__eq__`, they should be just compared by identity. >From performance point of view, both PRs look good. Maybe we can even combine >both, so that we have both fine-tuned repr and pickleability. I understand >this means we will get slower benchmarks for both creation and instantiation, >but I think it is still OK, since it is still much faster than creating a new >class. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue34963> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com