Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
It is faster to check hasattr than to catch the exception.
Browse files Browse the repository at this point in the history
  • Loading branch information
Travis Scrimshaw committed Jun 5, 2017
1 parent f9f4cea commit 16f7c09
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/sage/rings/polynomial/polynomial_element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -7307,10 +7307,8 @@ cdef class Polynomial(CommutativeAlgebraElement):
# If the base ring has a method _roots_univariate_polynomial,
# try to use it. An exception is raised if the method does not
# handle the current parameters
try:
if hasattr(K, '_roots_univariate_polynomial'):
return K._roots_univariate_polynomial(self, ring=ring, multiplicities=multiplicities, algorithm=algorithm, **kwds)
except (AttributeError, NotImplementedError):
pass

if kwds:
raise TypeError("roots() got unexpected keyword argument(s): {}".format(kwds.keys()))
Expand Down

0 comments on commit 16f7c09

Please sign in to comment.