Message328707
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. |
|
Date |
User |
Action |
Args |
2018-10-28 16:51:55 | levkivskyi | set | recipients:
+ levkivskyi, serhiy.storchaka, fish2000 |
2018-10-28 16:51:55 | levkivskyi | set | messageid: <1540745515.8.0.788709270274.issue34963@psf.upfronthosting.co.za> |
2018-10-28 16:51:55 | levkivskyi | link | issue34963 messages |
2018-10-28 16:51:55 | levkivskyi | create | |
|