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

Faster get_unsafe for NTL GF(p) polynomials #35455

Merged
merged 1 commit into from
Apr 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/sage/libs/ntl/ntl_ZZ_pX.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,7 @@ cdef class ntl_ZZ_pX():
if i < 0:
r.set_from_int(0)
else:
sig_on()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why you are removing this sig_on/sig_off pair.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit unrelated but calling sig_on/sig_off is slightly costly (not that much) and documentation says it should apply to possibly long computations and it seems we are not in this case since this getter does not do anything. Also __setitem__ does not do the sig_on/sig_off

I'm totally fine to split this off this pull request if you advise so.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, that's fine, I just wasn't sure if it was intentional. Thanks!

r.x = ZZ_pX_coeff( self.x, i)
sig_off()
return r

cdef int getitem_as_int(ntl_ZZ_pX self, long i):
Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/polynomial/polynomial_modn_dense_ntl.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ cdef class Polynomial_dense_mod_n(Polynomial):
sage: f[:3]
13*x^2 + 10*x + 5
"""
return self._parent._base(self.__poly[n]._sage_())
return self._parent._base((<ntl_ZZ_pX> self.__poly)[n]._integer_())

def _unsafe_mutate(self, n, value):
n = int(n)
Expand Down