Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop return type from arithmetic methods in coercion model #20740

Closed
jdemeyer opened this issue May 31, 2016 · 13 comments
Closed

Drop return type from arithmetic methods in coercion model #20740

jdemeyer opened this issue May 31, 2016 · 13 comments

Comments

@jdemeyer
Copy link
Contributor

Replace

cpdef ModuleElement _add_(left, ModuleElement right)

by

cpdef _add_(left, ModuleElement right)

and similar. The return type serves no purpose:

  1. if you really do need any information of the return type, then something like ModuleElement is too generic anyway.
  2. 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.

CC: @videlec

Component: coercion

Keywords: days74

Author: Jeroen Demeyer

Branch: 56776e2

Reviewer: Marc Mezzarobba

Issue created by migration from https://trac.sagemath.org/ticket/20740

@jdemeyer jdemeyer added this to the sage-7.3 milestone May 31, 2016
@jdemeyer

This comment has been minimized.

@jdemeyer

This comment has been minimized.

@jdemeyer
Copy link
Contributor Author

jdemeyer commented Jun 1, 2016

comment:3

(edit: wrong ticket)

@jdemeyer
Copy link
Contributor Author

jdemeyer commented Jun 1, 2016

Branch: u/jdemeyer/drop_return_type

@jdemeyer
Copy link
Contributor Author

jdemeyer commented Jun 1, 2016

New commits:

56776e2Drop return type from single-underscore arithmetic methods

@jdemeyer
Copy link
Contributor Author

jdemeyer commented Jun 1, 2016

Commit: 56776e2

@jdemeyer
Copy link
Contributor Author

jdemeyer commented Jun 2, 2016

Changed keywords from none to days74

@mezzarobba
Copy link
Member

comment:7

Sounds convincing, though I would have preferred someone with stronger Cython-fu 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).

@mezzarobba
Copy link
Member

Reviewer: Marc Mezzarobba

@jdemeyer
Copy link
Contributor Author

comment:9

Replying to @mezzarobba:

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.

@jdemeyer jdemeyer changed the title Drop return type from single-underscore arithmetic methods Drop return type from arithmetic methods in coercion model Jun 15, 2016
@vbraun
Copy link
Member

vbraun commented Jun 15, 2016

Changed branch from u/jdemeyer/drop_return_type to 56776e2

@williamstein
Copy link
Contributor

Changed commit from 56776e2 to none

@williamstein
Copy link
Contributor

comment:12

test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants