#20740 closed defect (fixed)
Drop return type from arithmetic methods in coercion model
Reported by:  Jeroen Demeyer  Owned by:  

Priority:  major  Milestone:  sage7.3 
Component:  coercion  Keywords:  days74 
Cc:  Vincent Delecroix  Merged in:  
Authors:  Jeroen Demeyer  Reviewers:  Marc Mezzarobba 
Report Upstream:  N/A  Work issues:  
Branch:  56776e2 (Commits, GitHub, GitLab)  Commit:  
Dependencies:  Stopgaps: 
Description (last modified by )
Replace
cpdef ModuleElement _add_(left, ModuleElement right)
by
cpdef _add_(left, ModuleElement right)
and similar. The return type serves no purpose:
 if you really do need any information of the return type, then something like
ModuleElement
is too generic anyway.  it forces Cython to add some checks that the returned value is of the correct type, so it might actually slow down things.
Also remove the superfluous declarations of these methods in other .pxd
files.
Change History (12)
comment:1 Changed 7 years ago by
Description:  modified (diff) 

comment:2 Changed 7 years ago by
Description:  modified (diff) 

comment:4 Changed 6 years ago by
Branch:  → u/jdemeyer/drop_return_type 

comment:5 Changed 6 years ago by
Commit:  → 56776e26371ba92fcab8aaa33500835b78ad64fa 

Status:  new → needs_review 
New commits:
56776e2  Drop return type from singleunderscore arithmetic methods

comment:6 Changed 6 years ago by
Keywords:  days74 added 

comment:7 followup: 9 Changed 6 years ago by
Status:  needs_review → positive_review 

Sounds convincing, though I would have preferred someone with stronger Cythonfu than me to review the ticket :)
. This does make a few generated C files a couple hundred lines smaller, but I didn't notice any significant performance change (either way).
comment:8 Changed 6 years ago by
Reviewers:  → Marc Mezzarobba 

comment:9 Changed 6 years ago by
Replying to mmezzarobba:
but I didn't notice any significant performance change (either way).
I'm not surprised. The overhead of these checks should be small compared to the actual operation.
Thanks for the review of this and related tickets.
comment:10 Changed 6 years ago by
Summary:  Drop return type from singleunderscore arithmetic methods → Drop return type from arithmetic methods in coercion model 

comment:11 Changed 6 years ago by
Branch:  u/jdemeyer/drop_return_type → 56776e26371ba92fcab8aaa33500835b78ad64fa 

Resolution:  → fixed 
Status:  positive_review → closed 
(edit: wrong ticket)