You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Move real/complex interval fields to new coercion model #24371
- cdef ComplexIntervalFieldElement res = self._new()+ res = self._new()
aren't we loosing some efficiency? I would think because they are still subclasses of ComplexIntervalFieldElement, that Cython would be able to optimize their attribute lookups by not treating them as Python objects? (Of course, we would have to explicitly cast <ComplexIntervalFieldElement> to avoid the type-checking-safety-penalty.)
This goes through the __call__ (which in this case, bypasses the coercion framework, but normally it wouldn't):
- cdef ComplexIntervalFieldElement res = self._new()+ res = self._new()
aren't we loosing some efficiency?
No, Cython has type inference. Since _new is declared as returning a ComplexIntervalFieldElement, the declaration cdef ComplexIntervalFieldElement res is just redundant.
This goes through the __call__ (which in this case, bypasses the coercion framework, but normally it wouldn't):
Cython would be able to optimize their attribute lookups by not treating them as Python objects?
Actually, the relevant attributes are cdef attributes, so they cannot even be accessed from Python! So the fact that the code works proves that Cython must be doing type inference.
I changed some self(...) calls to self.element_class(self, ...)
Cython would be able to optimize their attribute lookups by not treating them as Python objects?
Actually, the relevant attributes are cdef attributes, so they cannot even be accessed from Python! So the fact that the code works proves that Cython must be doing type inference.
I changed some self(...) calls to self.element_class(self, ...)
Thank you. LGTM. (If I wanted to be really picky, I would say self.element_class(self, 1) should instead use the cached self.one(), but zeta(1) is almost certainly never called.)
Activity
jdemeyer commentedon Dec 13, 2017
Branch: u/jdemeyer/move_real_complex_interval_fields_to_new_coercion_model
sagetrac-git commentedon Dec 14, 2017
Commit:
db4611asagetrac-git commentedon Dec 14, 2017
Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:
375e40fMap._extra_slots(): do not pass dictdb4611aMove real/complex interval fields to new coercion modeljdemeyer commentedon Dec 14, 2017
Author: Jeroen Demeyer
jdemeyer commentedon Dec 14, 2017
Dependencies: #24372
sagetrac-git commentedon Dec 14, 2017
Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:
549bd7dMove real/complex interval fields to new coercion modelsagetrac-git commentedon Dec 14, 2017
Changed commit from
db4611ato549bd7dsagetrac-git commentedon Dec 15, 2017
Changed commit from
549bd7dtofe4c823sagetrac-git commentedon Dec 15, 2017
Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:
fe4c823Move real/complex interval fields to new coercion modeljdemeyer commentedon Dec 15, 2017
sagetrac-git commentedon Dec 15, 2017
Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:
2cee3a4Move real/complex interval fields to new coercion model57 remaining items
sagetrac-git commentedon Feb 12, 2018
Branch pushed to git repo; I updated commit sha1. New commits:
22d309cCleanup for real/complex interval fieldsjdemeyer commentedon Feb 12, 2018
I ended up doing a lot of cleanup. I think I'm using
element_classeverywhere, but don't shoot me if I'm wrong.Note that currently the category stuff won't be used anyway because the elements are extension types.
tscrim commentedon Feb 13, 2018
Thank you for doing the cleanup.
For changes such as
aren't we loosing some efficiency? I would think because they are still subclasses of
ComplexIntervalFieldElement, that Cython would be able to optimize their attribute lookups by not treating them as Python objects? (Of course, we would have to explicitly cast<ComplexIntervalFieldElement>to avoid the type-checking-safety-penalty.)This goes through the
__call__(which in this case, bypasses the coercion framework, but normally it wouldn't):I think we are better making a direct call to
self.element_class(self, 0, 1)since this is not user input.jdemeyer commentedon Feb 13, 2018
Replying to @tscrim:
No, Cython has type inference. Since
_newis declared as returning aComplexIntervalFieldElement, the declarationcdef ComplexIntervalFieldElement resis just redundant.I don't see the problem with using
__call__here but I can make that change.sagetrac-git commentedon Feb 13, 2018
Changed commit from
22d309cto9ac1612sagetrac-git commentedon Feb 13, 2018
Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:
9ac1612Cleanup for real/complex interval fieldsjdemeyer commentedon Feb 13, 2018
Replying to @tscrim:
Actually, the relevant attributes are
cdefattributes, so they cannot even be accessed from Python! So the fact that the code works proves that Cython must be doing type inference.I changed some
self(...)calls toself.element_class(self, ...)tscrim commentedon Feb 13, 2018
Replying to @jdemeyer:
That is what is happening, e.g.:
I didn't realize that Cython was that smart. :)
Thank you. LGTM. (If I wanted to be really picky, I would say
self.element_class(self, 1)should instead use the cachedself.one(), butzeta(1)is almost certainly never called.)jdemeyer commentedon Feb 13, 2018
Thanks!
vbraun commentedon Feb 15, 2018
Changed branch from public/24371-move_real_complex_interval_fields_to_new_coercion_model to
9ac1612