Message194488
On 03/08/13 13:22, Alexander Belopolsky wrote:
>
> Alexander Belopolsky added the comment:
>
> The implementation of median and mode families of functions as classes is clever,
So long as it is not too clever.
> but I am not sure it is a good idea to return something other than an instance of the class from __new__().
Returning foreign instances is supported behaviour for __new__. (If the object returned from __new__ is not an instance, __init__ is not called.) I believe the current implementation is reasonable and prefer to keep it. If I use the traditional implementation, there will only be one instance, with no state, only methods. That's a rather poor excuse for an instance, and a class already is a singleton object with methods and (in this case) no state, so creating an instance as well adds nothing.
I will change the implementation if the consensus among senior devs is against it, but would prefer not to. |
|
Date |
User |
Action |
Args |
2013-08-05 15:33:47 | steven.daprano | set | recipients:
+ steven.daprano, gregory.p.smith, ronaldoussoren, belopolsky, pitrou, agthorr, christian.heimes, stutzbach, tshepang, vajrasky |
2013-08-05 15:33:47 | steven.daprano | link | issue18606 messages |
2013-08-05 15:33:46 | steven.daprano | create | |
|