Serhiy Storchaka <storchaka+cpyt...@gmail.com> added the comment:

I'm not sure that this should be in the stdlib. The three-line function can be 
enough for your simple case, and it is too simple for including it in the 
stdlib. But for general stdlib quality solution it lacks many details.

1. It doesn't work with classes that implement the constructor as __new__, but 
not __init__. It may need of using metaclasses with overridden __call__. But 
how then handle classes with custom metaclasses?

2. inspect.signature() doesn't give the correct signature as for partial(). 
This requires changing the inspect module.

3. pickling and copying of instances are broken in many cases. Pickling a class 
is always broken. I afraid that this can't be solved without significant 
reworking of the pickle and the copy modules.

4. It adds instance attributes __dict__ and __weakref__ even if they were 
disabled by using __slots__. This increases the size of instances and breaks 
some properties.

5. repr() of the class doesn't show that it is a partialclass (unlike to the 
result of partial()).

6. Many alternate constructors and copying methods are broken. For example the 
copy() method of partialclass(defaultdict, list) in your example. There is no 
general solution of this, it should be solved individually for every class.

If there is a need of this feature in the stdlib, it needs changing many parts 
of the stdlib. And the result will still need an additional work for every 
concrete class.

Also note that the term "partial class" has different well known meaning in 
some other programming languages: 
https://en.wikipedia.org/wiki/Class_(computer_programming)#Partial .

----------
nosy: +serhiy.storchaka

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue33419>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to