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

Commit 16f7c09

Browse files
author
Travis Scrimshaw
committed
It is faster to check hasattr than to catch the exception.
1 parent f9f4cea commit 16f7c09

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

src/sage/rings/polynomial/polynomial_element.pyx

+1-3
Original file line numberDiff line numberDiff line change
@@ -7307,10 +7307,8 @@ cdef class Polynomial(CommutativeAlgebraElement):
73077307
# If the base ring has a method _roots_univariate_polynomial,
73087308
# try to use it. An exception is raised if the method does not
73097309
# handle the current parameters
7310-
try:
7310+
if hasattr(K, '_roots_univariate_polynomial'):
73117311
return K._roots_univariate_polynomial(self, ring=ring, multiplicities=multiplicities, algorithm=algorithm, **kwds)
7312-
except (AttributeError, NotImplementedError):
7313-
pass
73147312

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

0 commit comments

Comments
 (0)