PEP: add __sum__ method

D

dmitrey

hi all,
could you consider adding __sum__ method, e.g. Python sum(a) checks
does a have attribute __sum__ and if it has, then a.__sum__() is
invoked instead of Python sum(a).
(for my soft FuncDesigner it would be very essential, I guess for many
other soft as well, e.g. for PuLP, who has to use lpSum, because
ordinary Python sum slows it very much, as well as my funcs, and for
large-scale problems max recursion depth is exeeded).
Regards, D.
 
S

Steven D'Aprano

hi all,
could you consider adding __sum__ method, e.g. Python sum(a) checks does
a have attribute __sum__ and if it has, then a.__sum__() is invoked
instead of Python sum(a).
(for my soft FuncDesigner it would be very essential, I guess for many
other soft as well, e.g. for PuLP, who has to use lpSum, because
ordinary Python sum slows it very much, as well as my funcs, and for
large-scale problems max recursion depth is exeeded). Regards, D.

A cautious +0.5 on that. I think I would need to see more detailed
justification before making it +1.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,151
Messages
2,570,854
Members
47,394
Latest member
Olekdev

Latest Threads

Top