Ah, S = R.__class__(R.base_ring(), len(Z), [str(z) for z in Z], R.term_order()) is silly, because it bypasses the caching mechanism.
In fact, I'm not sure anymore whether I am on the right track: the basic problem is described at the bottom of https://github.com/sagemath/sage/pull/38108. Looking at %prun (see below), I thought that a lot of time is wasted in constructing polynomial rings, especially the number of calls to PolynomialRing seems very large to me. However, looking at sage.rings.polynomial.polynomial_ring_constructor._cache.keys(), these are actually all have very few generators (at most 7), so the title of this post ("many generators") is completely wrong. It may still be problematic that `_gcd_univariate_polynomial` constructs them so often. I'll investigate further. Help would be very much appreciated, of course. Martin %prun -s cumulative repr(D) 92714635 function calls (92104545 primitive calls) in 71.609 seconds Ordered by: cumulative time ncalls tottime percall cumtime percall filename:lineno(function) 1 0.000 0.000 71.783 71.783 {built-in method builtins.exec} 1 0.000 0.000 71.783 71.783 <string>:1(<module>) 790/1 0.002 0.000 71.783 71.783 {built-in method builtins.repr} 141/1 0.000 0.000 71.783 71.783 lazy_series.py:1550(_repr_) 29/1 0.001 0.000 71.783 71.783 lazy_series.py:5930(_format_series) 29/1 0.000 0.000 71.776 71.776 lazy_series.py:5959(<listcomp>) 100/11 0.000 0.000 71.775 6.525 lazy_series.py:320(__getitem__) 62/11 0.000 0.000 71.775 6.525 stream.py:1782(__getitem__) 7 0.000 0.000 71.775 10.254 stream.py:2096(_compute) 996 0.006 0.000 67.615 0.068 infinite_polynomial_element.py:1266(gcd) 17828/996 0.851 0.000 67.579 0.068 {method 'gcd' of 'sage.rings.polynomial.multi_polynomial.MPolynomial' objects} 18124/990 0.204 0.000 62.978 0.064 unique_factorization_domains.py:132(_gcd_univariate_polynomial) 1788/1062 0.026 0.000 55.622 0.052 fraction_field.py:560(_element_constructor_) 7 0.001 0.000 51.446 7.349 stream.py:2046(_solve_linear_equations_and_subs) 28 0.008 0.000 51.324 1.833 stream.py:1900(_subs_in_caches) 402 0.004 0.000 51.111 0.127 {method 'map_coefficients' of 'sage.rings.polynomial.multi_polynomial.MPolynomial' objects} 713 0.001 0.000 50.436 0.071 stream.py:1964(<lambda>) 713 0.019 0.000 50.435 0.071 stream.py:1922(subs) 233237/233209 0.949 0.000 46.016 0.000 multi_polynomial_element.py:457(_repr_) 233237/233209 4.064 0.000 44.502 0.000 {method 'poly_repr' of 'sage.rings.polynomial.polydict.PolyDict' objects} 1517930 2.132 0.000 43.219 0.000 magmatic_algebras.py:208(_product_from_product_on_basis_multiply) 1517930 1.505 0.000 40.697 0.000 free_module.py:1054(linear_combination) 1517930 4.470 0.000 38.232 0.000 {built-in method sage.data_structures.blas_dict.linear_combination} 183026/182240 1.749 0.000 34.106 0.000 polynomial_ring_constructor.py:60(PolynomialRing) 3034737 1.263 0.000 33.762 0.000 free_module.py:1078(<genexpr>) 3034737 2.818 0.000 32.499 0.000 magmatic_algebras.py:222(<genexpr>) 183026/182666 0.943 0.000 30.224 0.000 {built-in method sage.structure.category_object.normalize_names} 1516807 4.375 0.000 29.414 0.000 multiplicative.py:41(product_on_basis) 7 0.000 0.000 20.329 2.904 stream.py:1983(_collect_equations) 71/7 0.000 0.000 20.321 2.903 stream.py:396(__getitem__) 28/7 0.000 0.000 20.321 2.903 stream.py:2741(get_coefficient) 226182/164092 0.072 0.000 17.707 0.000 {built-in method builtins.sum} 24/19 0.000 0.000 17.654 0.929 stream.py:2808(get_coefficient) 24/19 0.000 0.000 17.654 0.929 additive_monoids.py:52(sum) 52/42 0.000 0.000 17.582 0.419 stream.py:2827(<genexpr>) 17861 0.111 0.000 15.377 0.001 polynomial_singular_interface.py:181(_singular_) 17861 0.366 0.000 15.266 0.001 polynomial_singular_interface.py:348(_singular_init_) 1516811 1.379 0.000 12.021 0.000 poor_man_map.py:241(__call__) 103578/87895 0.835 0.000 11.820 0.000 multi_polynomial_ring.py:177(__call__) 10284/8981 0.165 0.000 10.894 0.001 multi_polynomial_element.py:321(_mul_) 1516807 1.980 0.000 10.686 0.000 partition.py:462(__classcall_private__) 1516811 8.360 0.000 10.642 0.000 free_module.py:1106(_monomial) 12991 0.154 0.000 9.839 0.001 multi_polynomial_element.py:1849(_floordiv_) 109401 0.631 0.000 9.452 0.000 sfa.py:3241(gcd) 1626805 2.513 0.000 8.706 0.000 partition.py:6350(_element_constructor_) 35668/35580 0.190 0.000 8.503 0.000 rings.py:1148(__getitem__) 1454 0.017 0.000 6.957 0.005 multi_polynomial_element.py:121(__call__) 111193 0.404 0.000 6.924 0.000 sfa.py:6841(_to_polynomials) 7 0.000 0.000 6.363 0.909 lazy_series.py:5265(coefficient) 82/63 0.001 0.000 5.441 0.086 lazy_series_ring.py:2648(_element_constructor_) 1738587 1.196 0.000 5.187 0.000 partition.py:518(__init__) 443 0.005 0.000 4.027 0.009 fraction_field.py:712(resolve_fractions) 12497 0.297 0.000 3.871 0.000 multi_polynomial_ring.py:565(monomial_quotient) 14242 0.031 0.000 3.856 0.000 multi_polynomial_element.py:356(_rmul_) 14242 0.177 0.000 3.775 0.000 {method 'scalar_rmult' of 'sage.rings.polynomial.polydict.PolyDict' objects} 1738587 2.717 0.000 3.752 0.000 combinat.py:1526(__init__) 1326 0.003 0.000 3.042 0.002 multi_polynomial_element.py:335(_lmul_) 1326 0.016 0.000 3.033 0.002 {method 'scalar_lmult' of 'sage.rings.polynomial.polydict.PolyDict' objects} 28 0.001 0.000 2.644 0.094 multi_polynomial_element.py:307(_sub_) 1426 0.091 0.000 2.622 0.002 multi_polynomial_element.py:1432(subs) 107192 0.399 0.000 2.374 0.000 sfa.py:6873(<listcomp>) 3089637 1.873 0.000 2.165 0.000 free_module.py:1204(_from_dict) 15888578 2.153 0.000 2.153 0.000 {built-in method builtins.isinstance} 29 0.000 0.000 2.138 0.074 fraction_field.py:351(wrapper) 111193 0.328 0.000 2.015 0.000 sfa.py:6879(_from_polynomial) 456555/234169 0.361 0.000 1.912 0.000 {built-in method builtins.max} 110451 0.183 0.000 1.898 0.000 sfa.py:1797(is_unit) 103141/103022 0.288 0.000 1.863 0.000 {method 'coerce' of 'sage.structure.parent.Parent' objects} 5014 0.093 0.000 1.765 0.000 {method 'pseudo_quo_rem' of 'sage.rings.polynomial.polynomial_element.Polynomial' objects} 333579 0.259 0.000 1.745 0.000 sfa.py:6866(<genexpr>) 109994 0.802 0.000 1.657 0.000 modules_with_basis.py:1520(coefficient) 242646 1.101 0.000 1.587 0.000 polynomial_ring.py:336(_element_constructor_) 296 0.013 0.000 1.431 0.005 fraction_field.py:942(_gcd_univariate_polynomial) 107192 0.700 0.000 1.427 0.000 sfa.py:6905(<dictcomp>) 1737437 0.895 0.000 1.287 0.000 partition.py:6394(__contains__) 3234864 0.817 0.000 1.194 0.000 combinat.py:1447(__iter__) 708 0.002 0.000 1.090 0.002 infinite_polynomial_element.py:698(_lmul_) 137507/133349 0.151 0.000 1.065 0.000 multi_polynomial_element.py:1820(__eq__) 408 0.003 0.000 1.042 0.003 {method 'numerator' of 'sage.rings.polynomial.multi_polynomial.MPolynomial' objects} 592 0.010 0.000 1.026 0.002 {method 'numerator' of 'sage.rings.polynomial.polynomial_element.Polynomial' objects} 3234741 0.692 0.000 1.021 0.000 combinat.py:1421(__len__) 150040/149686 0.147 0.000 1.009 0.000 polynomial_ring_constructor.py:750(_single_variate) 1738587 0.680 0.000 1.002 0.000 partition.py:550(__hash__) 32986 0.152 0.000 0.967 0.000 polynomial_ring_constructor.py:831(_multi_variate) 7241407/7040280 0.848 0.000 0.908 0.000 {built-in method builtins.len} 112 0.000 0.000 0.904 0.008 lazy_series.py:2976(_mul_) 9 0.000 0.000 0.897 0.100 lazy_series.py:3091(<listcomp>) 18 0.000 0.000 0.897 0.050 lazy_series.py:3091(<genexpr>) 12647 0.012 0.000 0.882 0.000 {method 'is_one' of 'sage.structure.element.RingElement' objects} 1738587 0.841 0.000 0.841 0.000 combinat.py:1111(__init__) 222386 0.722 0.000 0.822 0.000 modules_with_basis.py:1651(support) 111782 0.265 0.000 0.688 0.000 partition.py:6615(from_exp) 214384 0.171 0.000 0.671 0.000 sfa.py:6873(<dictcomp>) 226135 0.338 0.000 0.636 0.000 term_order.py:999(sortkey_degrevlex) 183026 0.111 0.000 0.615 0.000 polynomial_ring_constructor.py:740(_get_from_cache) 20353/20206 0.019 0.000 0.598 0.000 multi_polynomial_ring.py:502(<dictcomp>) 32986 0.274 0.000 0.594 0.000 term_order.py:570(__init__) 144787 0.264 0.000 0.576 0.000 multi_polynomial_element.py:425(__init__) 201127 0.300 0.000 0.568 0.000 partition.py:3770(to_exp) 377/365 0.007 0.000 0.547 0.001 infinite_polynomial_ring.py:858(_element_constructor_) 7 0.000 0.000 0.537 0.077 lazy_series_ring.py:2833(<listcomp>) 183026 0.227 0.000 0.504 0.000 {method 'get' of 'sage.misc.weak_dict.WeakValueDictionary' objects} 873167 0.397 0.000 0.493 0.000 combinat.py:1202(__eq__) 1208 0.004 0.000 0.439 0.000 polynomial_ring.py:1928(__init__) 51473 0.172 0.000 0.432 0.000 multi_polynomial_element.py:827(__iter__) 1210 0.009 0.000 0.432 0.000 polynomial_ring.py:1801(__init__) 1210 0.051 0.000 0.420 0.000 polynomial_ring.py:246(__init__) 1894151/1836583 0.378 0.000 0.418 0.000 {built-in method builtins.hash} 3267511 0.409 0.000 0.409 0.000 {method 'monomial_coefficients' of 'sage.modules.with_basis.indexed_element.IndexedFreeModuleElement' objects} 638 0.024 0.000 0.392 0.001 classical.py:90(_element_constructor_) 3272864 0.386 0.000 0.386 0.000 {built-in method builtins.iter} 3491586 0.337 0.000 0.337 0.000 {method 'items' of 'dict' objects} 28565 0.086 0.000 0.301 0.000 multi_polynomial_element.py:571(degree) 1210 0.005 0.000 0.298 0.000 unital_algebras.py:74(__init_extra__) 1210 0.037 0.000 0.286 0.000 polynomial_ring.py:706(_coerce_map_from_base_ring) 259200 0.135 0.000 0.284 0.000 term_order.py:888(sortkey) 1516807 0.281 0.000 0.281 0.000 {method 'sort' of 'list' objects} 37976 0.010 0.000 0.264 0.000 {built-in method builtins.next} 1111 0.003 0.000 0.257 0.000 polynomial_ring.py:2159(__init__) 868 0.006 0.000 0.239 0.000 multi_polynomial_element.py:940(coefficient) 423513 0.214 0.000 0.238 0.000 support_view.py:102(__iter__) 2245496 0.230 0.000 0.230 0.000 {method 'base_ring' of 'sage.structure.category_object.CategoryObject' objects} 1792 0.019 0.000 0.226 0.000 sfa.py:3202(_floordiv_) 776 0.007 0.000 0.221 0.000 {method 'format' of 'str' objects} 21915 0.151 0.000 0.219 0.000 {method '_mpoly_dict_recursive' of 'sage.rings.polynomial.polynomial_element.Polynomial' objects} 184753 0.186 0.000 0.212 0.000 {method 'remove_zeros' of 'sage.rings.polynomial.polydict.PolyDict' objects} 54371 0.038 0.000 0.210 0.000 unital_algebras.py:354(from_base_ring_from_one_basis) 868 0.017 0.000 0.209 0.000 multi_polynomial_element.py:1373(is_monomial) 272 0.001 0.000 0.201 0.001 stream.py:1936(fix_cache) 4448 0.015 0.000 0.191 0.000 infinite_polynomial_element.py:1628(_richcmp_) 32785 0.030 0.000 0.186 0.000 re.py:232(findall) 25879 0.053 0.000 0.186 0.000 multi_polynomial_element.py:1211(_exponents) 183090 0.104 0.000 0.184 0.000 {built-in method builtins.any} 17855 0.082 0.000 0.176 0.000 polynomial_singular_interface.py:52(_do_singular_init_) 1550 0.007 0.000 0.174 0.000 {sage.misc.misc_c.prod} 1210 0.013 0.000 0.173 0.000 polynomial_ring.py:1240(gen) 54896 0.055 0.000 0.173 0.000 free_module.py:1083(term) 1546536 0.173 0.000 0.173 0.000 {method 'one' of 'sage.rings.ring.Ring' objects} 290 0.011 0.000 0.172 0.001 {method 'monic' of 'sage.rings.polynomial.polynomial_element.Polynomial' objects} 1536888 0.166 0.000 0.166 0.000 {method 'parent' of 'sage.structure.element.Element' objects} 262784 0.151 0.000 0.151 0.000 {built-in method builtins.getattr} 28784 0.052 0.000 0.146 0.000 multi_polynomial_ring.py:166(__hash__) 15174 0.034 0.000 0.143 0.000 {method 'coefficients' of 'sage.rings.polynomial.polynomial_element.Polynomial' objects} 4001 0.059 0.000 0.138 0.000 sfa.py:6875(<listcomp>) 82221 0.103 0.000 0.138 0.000 monoids.py:277(is_one) 1312/1310 0.008 0.000 0.138 0.000 polynomial_ring.py:734(_coerce_map_from_) 19069 0.089 0.000 0.133 0.000 polynomial_singular_interface.py:382(can_convert_to_singular) 631 0.000 0.000 0.129 0.000 infinite_polynomial_element.py:271(_repr_) 3939/2632 0.042 0.000 0.126 0.000 homset.py:87(Hom) 402 0.001 0.000 0.125 0.000 infinite_polynomial_element.py:555(numerator) 473 0.002 0.000 0.122 0.000 infinite_polynomial_element.py:1683(_mul_) 1507/1505 0.006 0.000 0.121 0.000 {method 'coerce_map_from' of 'sage.structure.parent.Parent' objects} 116841 0.076 0.000 0.121 0.000 multi_polynomial_element.py:805(monomial_coefficients) 107192 0.117 0.000 0.117 0.000 {method 'monomial_coefficients' of 'sage.rings.polynomial.polynomial_element.Polynomial' objects} 111193 0.115 0.000 0.115 0.000 sfa.py:6871(<listcomp>) 144787 0.114 0.000 0.114 0.000 multi_polynomial_element.py:93(__init__) 233266 0.111 0.000 0.111 0.000 {method '_repr_option' of 'sage.structure.parent.Parent' objects} 5151 0.003 0.000 0.109 0.000 {built-in method sage.structure.richcmp.richcmp} 22917 0.066 0.000 0.109 0.000 multi_polynomial_element.py:1352(is_generator) 10704/4397 0.071 0.000 0.104 0.000 {method 'has_coerce_map_from' of 'sage.structure.parent.Parent' objects} 32785 0.104 0.000 0.104 0.000 {method 'findall' of 're.Pattern' objects} 35668 0.102 0.000 0.102 0.000 rings.py:1365(<listcomp>) 7 0.007 0.001 0.100 0.014 {method 'solve_right' of 'sage.matrix.matrix2.Matrix' objects} 12497 0.040 0.000 0.100 0.000 multi_polynomial_ring.py:771(monomial_divides) 100617 0.068 0.000 0.096 0.000 <frozen importlib._bootstrap>:404(parent) 4001 0.057 0.000 0.095 0.000 sfa.py:6908(<dictcomp>) 99/97 0.001 0.000 0.094 0.001 fraction_field.py:219(_coerce_map_from_) 486632 0.091 0.000 0.091 0.000 multi_polynomial_element.py:416(element) 25886 0.026 0.000 0.090 0.000 {built-in method builtins.sorted} 249052 0.088 0.000 0.088 0.000 {method 'nonzero_values' of 'sage.rings.polynomial.polydict.ETuple' objects} 10326 0.015 0.000 0.088 0.000 multi_polynomial_element.py:440(_new_constant_poly) 226135 0.087 0.000 0.087 0.000 {method 'reversed' of 'sage.rings.polynomial.polydict.ETuple' objects} 28565 0.082 0.000 0.083 0.000 {method 'degree' of 'sage.rings.polynomial.polydict.PolyDict' objects} 8002 0.012 0.000 0.080 0.000 sfa.py:6875(<dictcomp>) 365957 0.080 0.000 0.080 0.000 polynomial_ring_constructor.py:639(<genexpr>) 65570 0.061 0.000 0.077 0.000 re.py:288(_compile) 32785 0.028 0.000 0.076 0.000 re.py:187(match) 64726 0.059 0.000 0.071 0.000 fraction_field.py:799(__hash__) 8527 0.025 0.000 0.070 0.000 rational_field.py:344(_coerce_map_from_) 14086 0.027 0.000 0.068 0.000 multi_polynomial_element.py:293(_add_) 17890 0.066 0.000 0.066 0.000 fraction_field.py:816(ngens) 17855 0.020 0.000 0.064 0.000 {method 'characteristic' of 'sage.rings.polynomial.multi_polynomial_ring_base.MPolynomialRing_base' objects} 32986 0.049 0.000 0.061 0.000 term_order.py:1907(__eq__) 159669 0.059 0.000 0.059 0.000 multi_polynomial_element.py:1839(__bool__) 226135 0.059 0.000 0.059 0.000 {method 'emul' of 'sage.rings.polynomial.polydict.ETuple' objects} 557 0.000 0.000 0.059 0.000 stream.py:1966(<lambda>) 557 0.007 0.000 0.058 0.000 stream.py:1929(retract) 201127 0.057 0.000 0.057 0.000 combinat.py:1377(__bool__) 319920 0.052 0.000 0.052 0.000 {method 'get' of 'dict' objects} 201 0.001 0.000 0.051 0.000 infinite_polynomial_element.py:688(_rmul_) 61770 0.034 0.000 0.046 0.000 term_order.py:865(__hash__) 1407 0.008 0.000 0.045 0.000 rings.py:489(_Hom_) 115744 0.045 0.000 0.045 0.000 {method 'base_ring' of 'sage.structure.element.Element' objects} 17855 0.014 0.000 0.045 0.000 fraction_field.py:465(characteristic) 119515 0.044 0.000 0.044 0.000 support_view.py:52(__init__) 172689 0.043 0.000 0.043 0.000 {method 'dict' of 'sage.rings.polynomial.polydict.PolyDict' objects} 2634 0.034 0.000 0.043 0.000 homset.py:610(__init__) 334489 0.042 0.000 0.042 0.000 {method 'zero' of 'sage.rings.ring.Ring' objects} 316129 0.041 0.000 0.041 0.000 {method 'term_order' of 'sage.rings.polynomial.multi_polynomial_ring_base.MPolynomialRing_base' objects} 2420 0.002 0.000 0.038 0.000 {built-in method sage.structure.category_object.check_default_category} 296 0.001 0.000 0.037 0.000 polynomial_ring.py:1083(change_ring) 136/92 0.001 0.000 0.037 0.000 repr.py:48(repr_lincomb) 1210 0.004 0.000 0.036 0.000 category.py:2281(join) 35668 0.023 0.000 0.035 0.000 rings.py:1325(normalize_arg) 1407 0.005 0.000 0.034 0.000 homset.py:46(RingHomset) 290454 0.033 0.000 0.033 0.000 {method 'variable_names' of 'sage.structure.category_object.CategoryObject' objects} 4630 0.031 0.000 0.032 0.000 polynomial_element_generic.py:1145(__init__) 3244 0.011 0.000 0.031 0.000 infinite_polynomial_element.py:180(__classcall_private__) 17855 0.016 0.000 0.031 0.000 algebras.py:146(characteristic) 112 0.000 0.000 0.030 0.000 infinite_polynomial_element.py:1397(_mul_) 16799 0.014 0.000 0.029 0.000 multi_polynomial_element.py:1828(__ne__) 312/192 0.000 0.000 0.029 0.000 repr.py:7(coeff_repr) 35 0.000 0.000 0.029 0.001 stream.py:1893(<genexpr>) 310/190 0.001 0.000 0.029 0.000 {method '_coeff_repr' of 'sage.structure.element.Element' objects} 1407 0.002 0.000 0.029 0.000 homset.py:78(__init__) 126545 0.028 0.000 0.028 0.000 {built-in method builtins.hasattr} 100617 0.028 0.000 0.028 0.000 {method 'rpartition' of 'str' objects} 1210 0.011 0.000 0.028 0.000 {built-in method sage.categories.category_cy_helper._sort_uniq} 27 0.000 0.000 0.027 0.001 qqbar_decorators.py:38(wrapper) 1407 0.002 0.000 0.027 0.000 homset.py:1267(__init__) 54896 0.026 0.000 0.026 0.000 free_module.py:1261(<dictcomp>) 27 0.000 0.000 0.026 0.001 multi_polynomial_element.py:2242(quo_rem) 5414 0.020 0.000 0.024 0.000 multi_polynomial_element.py:1503(constant_coefficient) 109994 0.023 0.000 0.023 0.000 {method 'is_unit' of 'sage.structure.element.FieldElement' objects} 32785 0.022 0.000 0.022 0.000 {method 'match' of 're.Pattern' objects} 4836 0.009 0.000 0.022 0.000 infinite_polynomial_element.py:248(__init__) 2260 0.005 0.000 0.019 0.000 multi_polynomial_element.py:186(<genexpr>) 60 0.001 0.000 0.018 0.000 lazy_series.py:3134(__pow__) 1307 0.011 0.000 0.018 0.000 magmas.py:791(__init_extra__) 85627 0.018 0.000 0.018 0.000 fraction_field.py:532(ring) 110202 0.017 0.000 0.017 0.000 polynomial_ring.py:1375(ngens) 12497 0.017 0.000 0.017 0.000 {method 'common_nonzero_positions' of 'sage.rings.polynomial.polydict.ETuple' objects} 17114 0.009 0.000 0.017 0.000 {built-in method builtins.all} 19557 0.007 0.000 0.017 0.000 category.py:1758(is_subcategory) 22917 0.015 0.000 0.016 0.000 {method 'is_one' of 'sage.rings.fraction_field_element.FractionFieldElement' objects} 21701 0.009 0.000 0.015 0.000 weakref.py:348(__new__) 23434 0.015 0.000 0.015 0.000 {method 'is_zero' of 'sage.rings.polynomial.polynomial_element.Polynomial' objects} 51 0.000 0.000 0.015 0.000 polynomial_element_generic.py:625(_mul_) 525 0.002 0.000 0.014 0.000 rings.py:1537(inverse_of_unit) 7826 0.009 0.000 0.013 0.000 multi_polynomial_ring.py:137(__eq__) 17855 0.013 0.000 0.013 0.000 rational_field.py:1003(characteristic) 3 0.000 0.000 0.013 0.004 stream.py:4783(_advance) 3862 0.011 0.000 0.011 0.000 dynamic_class.py:129(dynamic_class) 17861 0.010 0.000 0.011 0.000 fraction_field.py:450(base_ring) 51290 0.011 0.000 0.011 0.000 {method 'degree' of 'sage.rings.polynomial.polynomial_element.Polynomial_generic_dense' objects} 12497 0.011 0.000 0.011 0.000 {method 'divides' of 'sage.structure.element.FieldElement' objects} 969 0.001 0.000 0.011 0.000 infinite_polynomial_element.py:492(is_unit) 76016 0.011 0.000 0.011 0.000 {method 'ngens' of 'sage.rings.polynomial.multi_polynomial_ring_base.MPolynomialRing_base' objects} 9792 0.008 0.000 0.011 0.000 <frozen importlib._bootstrap>:1053(_handle_fromlist) 5 0.000 0.000 0.010 0.002 lazy_series_ring.py:1501(<genexpr>) 4 0.000 0.000 0.010 0.002 <ipython-input-14-11aeb329ac6b>:1(<lambda>) 969 0.005 0.000 0.010 0.000 {method 'is_unit' of 'sage.rings.polynomial.multi_polynomial.MPolynomial' objects} 19316 0.009 0.000 0.009 0.000 {method 'gens' of 'sage.structure.parent_gens.ParentWithGens' objects} 33187 0.009 0.000 0.009 0.000 term_order.py:2132(is_block_order) 17855 0.009 0.000 0.009 0.000 term_order.py:1648(singular_str) 20388 0.009 0.000 0.009 0.000 weakref.py:353(__init__) 97 0.002 0.000 0.008 0.000 polynomial_ring.py:627(flattening_morphism) 5137 0.005 0.000 0.008 0.000 copy.py:66(copy) 1210 0.003 0.000 0.008 0.000 {method '_populate_coercion_lists_' of 'sage.structure.parent.Parent' objects} 12497 0.007 0.000 0.007 0.000 {method 'esub' of 'sage.rings.polynomial.polydict.ETuple' objects} 6305 0.005 0.000 0.007 0.000 free_module.py:823(_coerce_map_from_) 33270 0.007 0.000 0.007 0.000 {method 'lower' of 'str' objects} 1210 0.002 0.000 0.007 0.000 magmatic_algebras.py:178(product) 18 0.000 0.000 0.007 0.000 lazy_series.py:1940(_acted_upon_) 703 0.002 0.000 0.007 0.000 infinite_polynomial_element.py:1498(_richcmp_) 2420 0.004 0.000 0.007 0.000 polynomial_ring_constructor.py:745(_save_in_cache) 4/1 0.000 0.000 0.007 0.007 stream.py:2722(_approximate_order) 7 0.000 0.000 0.007 0.001 multi_polynomial_sequence.py:719(coefficients_monomials) 4/3 0.000 0.000 0.007 0.002 stream.py:2789(_approximate_order) 32867 0.007 0.000 0.007 0.000 {method 'keys' of 'dict' objects} 21701 0.007 0.000 0.007 0.000 {built-in method __new__ of type object at 0x55a21f2709a0} 1 0.000 0.000 0.007 0.007 stream.py:4755(_approximate_order) 7252 0.004 0.000 0.006 0.000 category_types.py:377(_subcategory_hook_) 5 0.000 0.000 0.006 0.001 stream.py:4847(__getitem__) 3362 0.004 0.000 0.006 0.000 infinite_polynomial_element.py:351(__getattr__) 8685 0.004 0.000 0.006 0.000 category.py:638(_subcategory_hook_) 7 0.000 0.000 0.005 0.001 multi_polynomial_sequence.py:212(PolynomialSequence) 576 0.002 0.000 0.005 0.000 polynomial_ring.py:2122(construction) 408 0.002 0.000 0.005 0.000 {method 'denominator' of 'sage.rings.polynomial.multi_polynomial.MPolynomial' objects} 321 0.001 0.000 0.005 0.000 fraction_field.py:1228(_call_) 1210 0.004 0.000 0.005 0.000 {method 'register_coercion' of 'sage.structure.parent.Parent' objects} 32797 0.005 0.000 0.005 0.000 term_order.py:942(sortkey_lex) 13124 0.005 0.000 0.005 0.000 multi_polynomial_ring.py:807(<genexpr>) 525 0.002 0.000 0.005 0.000 algebras_with_basis.py:160(__invert__) 2420 0.002 0.000 0.005 0.000 rings.py:437(is_zero) 1210 0.004 0.000 0.004 0.000 {built-in method sage.categories.category_cy_helper._flatten_categories} 23244 0.004 0.000 0.004 0.000 combinat.py:1433(__getitem__) 1256 0.004 0.000 0.004 0.000 fields.py:65(__contains__) 16036 0.004 0.000 0.004 0.000 {built-in method builtins.issubclass} 816 0.002 0.000 0.004 0.000 multi_polynomial_element.py:1226(exponents) 6892 0.004 0.000 0.004 0.000 polynomial_ring.py:1027(__hash__) 1111 0.003 0.000 0.004 0.000 polynomial_ring.py:2186(_element_class) 10 0.000 0.000 0.004 0.000 lazy_series.py:2106(<listcomp>) 17855 0.003 0.000 0.003 0.000 rational_field.py:992(is_prime_field) 1220/1216 0.001 0.000 0.003 0.000 category.py:3046(is_subcategory) 1307 0.002 0.000 0.003 0.000 polynomial_ring.py:500(_implementation_names) 408 0.003 0.000 0.003 0.000 {method '_extract_polydict' of 'sage.rings.polynomial.multi_polynomial_ring_base.MPolynomialRing_base' objects} 584 0.003 0.000 0.003 0.000 pushout.py:828(__init__) 6903 0.003 0.000 0.003 0.000 partition.py:6434(<genexpr>) 2592 0.002 0.000 0.003 0.000 {method 'is_one' of 'sage.rings.polynomial.polynomial_element.Polynomial' objects} 868 0.003 0.000 0.003 0.000 {method 'polynomial_coefficient' of 'sage.rings.polynomial.polydict.PolyDict' objects} 35 0.000 0.000 0.003 0.000 infinite_polynomial_element.py:1670(_add_) 45 0.000 0.000 0.003 0.000 lazy_series.py:1767(_add_) 3 0.000 0.000 0.003 0.001 stream.py:4976(apply_operator) 97 0.000 0.000 0.003 0.000 category.py:597(_repr_) 3 0.000 0.000 0.002 0.001 lazy_series.py:1846(<listcomp>) 1210 0.002 0.000 0.002 0.000 {method '_make_weak_references' of 'sage.categories.map.Map' objects} 31 0.000 0.000 0.002 0.000 free_module.py:308(FreeModule) 97 0.000 0.000 0.002 0.000 category.py:499(_repr_object_names) 123 0.000 0.000 0.002 0.000 indexed_generators.py:332(_repr_generator) 42 0.000 0.000 0.002 0.000 free_module.py:6421(_element_constructor_) 324 0.001 0.000 0.002 0.000 {method 'join' of 'str' objects} 4001 0.002 0.000 0.002 0.000 {method 'iterator_exp_coeff' of 'sage.rings.polynomial.multi_polynomial_libsingular.MPolynomial_libsingular' objects} 49 0.001 0.000 0.002 0.000 free_module.py:2174(_element_constructor_) 18 0.000 0.000 0.002 0.000 free_module.py:245(create_object) 41 0.000 0.000 0.002 0.000 {method 'homogeneous_components' of 'sage.rings.polynomial.multi_polynomial.MPolynomial' objects} 1210 0.001 0.000 0.002 0.000 polynomial_ring.py:1291(is_exact) 5849 0.002 0.000 0.002 0.000 term_order.py:2144(is_weighted_degree_order) 483 0.001 0.000 0.002 0.000 free_module.py:897(is_exact) 7 0.000 0.000 0.002 0.000 multi_polynomial_sequence.py:568(monomials) 18 0.000 0.000 0.002 0.000 free_module.py:6073(__init__) 36 0.000 0.000 0.002 0.000 stream.py:918(_polynomial_part) 18 0.000 0.000 0.002 0.000 free_module.py:5360(__init__) 868 0.002 0.000 0.002 0.000 multi_polynomial_element.py:1016(<listcomp>) 18 0.000 0.000 0.002 0.000 free_module.py:1992(__init__) 7 0.000 0.000 0.002 0.000 infinite_polynomial_element.py:1367(_add_) 284 0.000 0.000 0.001 0.000 infinite_polynomial_element.py:281(__hash__) 8640 0.001 0.000 0.001 0.000 {built-in method sage.structure.element.parent} 2919 0.001 0.000 0.001 0.000 homset.py:1219(codomain) 7 0.000 0.000 0.001 0.000 {sage.modules.free_module_element.vector} 99 0.001 0.000 0.001 0.000 {method '__copy__' of 'sage.categories.map.Map' objects} 18 0.001 0.000 0.001 0.000 free_module.py:908(__init__) 6324 0.001 0.000 0.001 0.000 {function FreeModule_ambient._coerce_map_from_ at 0x7f858e182d40} 14 0.000 0.000 0.001 0.000 free_module.py:6242(__init__) 5165 0.001 0.000 0.001 0.000 homset.py:774(homset_category) 123 0.001 0.000 0.001 0.000 polynomial_element_generic.py:84(__init__) 53 0.000 0.000 0.001 0.000 {built-in method sage.structure.element.canonical_coercion} 701 0.001 0.000 0.001 0.000 multi_polynomial_element.py:1694(is_constant) 28 0.000 0.000 0.001 0.000 stream.py:1288(new_variable) 1228 0.001 0.000 0.001 0.000 additive_magmas.py:211(__init_extra__) 1273 0.001 0.000 0.001 0.000 fraction_field.py:763(__eq__) 123 0.000 0.000 0.001 0.000 partition.py:563(_repr_) 99 0.001 0.000 0.001 0.000 stream.py:621(__init__) 28 0.000 0.000 0.001 0.000 stream.py:1316(del_variable) 35 0.000 0.000 0.001 0.000 matrix_misc.py:24(row_iterator) 4769 0.001 0.000 0.001 0.000 {method 'category' of 'sage.rings.ring.Ring' objects} 11 0.000 0.000 0.001 0.000 free_module.py:6333(__init__) 1305 0.001 0.000 0.001 0.000 polynomial_ring.py:2086(_implementation_names_impl) 28 0.000 0.000 0.001 0.000 {method 'row' of 'sage.matrix.matrix1.Matrix' objects} 2919 0.001 0.000 0.001 0.000 homset.py:1204(domain) 2420 0.001 0.000 0.001 0.000 category.py:2997(super_categories) 1940 0.001 0.000 0.001 0.000 category.py:519(<genexpr>) 123 0.000 0.000 0.001 0.000 global_options.py:1643(_dispatch) 28 0.000 0.000 0.001 0.000 infinite_polynomial_element.py:611(monomials) 4 0.000 0.000 0.001 0.000 {method 'column' of 'sage.matrix.matrix1.Matrix' objects} 1550 0.001 0.000 0.001 0.000 polynomial_ring.py:1309(is_sparse) 56 0.000 0.000 0.001 0.000 {method 'add' of 'set' objects} 1210 0.001 0.000 0.001 0.000 abstract_method.py:202(__get__) 41 0.000 0.000 0.001 0.000 fraction_field.py:481(_repr_) 382 0.000 0.000 0.001 0.000 fraction_field.py:782(__ne__) 868 0.001 0.000 0.001 0.000 {method 'coefficients' of 'sage.rings.polynomial.polydict.PolyDict' objects} 18 0.000 0.000 0.001 0.000 category_with_axiom.py:1977(__classcall__) 3630 0.001 0.000 0.001 0.000 {method 'copy' of 'list' objects} 35 0.000 0.000 0.001 0.000 infinite_polynomial_ring.py:1267(gens_dict) 41 0.000 0.000 0.001 0.000 sfa.py:477(_repr_) 84 0.000 0.000 0.001 0.000 multi_polynomial_element.py:189(_richcmp_) 36 0.000 0.000 0.001 0.000 polynomial_element_generic.py:753(shift) 49 0.000 0.000 0.001 0.000 matrix_space.py:1036(_element_constructor_) 28 0.000 0.000 0.001 0.000 infinite_polynomial_element.py:590(variables) 1210 0.001 0.000 0.001 0.000 {method '_is_coercion_cached' of 'sage.structure.parent.Parent' objects} 42 0.000 0.000 0.001 0.000 matrix_space.py:677(__classcall__) 4001 0.001 0.000 0.001 0.000 {method 'ngens' of 'sage.rings.polynomial.multi_polynomial_libsingular.MPolynomialRing_libsingular' objects} 84 0.000 0.000 0.001 0.000 infinite_polynomial_element.py:1262(<genexpr>) 701 0.000 0.000 0.000 0.000 {method 'is_constant' of 'sage.rings.polynomial.polydict.PolyDict' objects} 28 0.000 0.000 0.000 0.000 multi_polynomial_element.py:1471(monomials) 18 0.000 0.000 0.000 0.000 modules.py:119(__classcall_private__) 7 0.000 0.000 0.000 0.000 {method 'right_kernel_matrix' of 'sage.matrix.matrix2.Matrix' objects} 3 0.000 0.000 0.000 0.000 {sage.modules.free_module_element.zero_vector} 448 0.000 0.000 0.000 0.000 monoids.py:293(_pow_int) 123 0.000 0.000 0.000 0.000 partition.py:687(_repr_list) 84 0.000 0.000 0.000 0.000 infinite_polynomial_ring.py:1455(__getitem__) 82 0.000 0.000 0.000 0.000 multi_polynomial_element.py:911(iterator_exp_coeff) 2062 0.000 0.000 0.000 0.000 {method 'numerator' of 'sage.rings.fraction_field_element.FractionFieldElement' objects} 7 0.000 0.000 0.000 0.000 stream.py:2021(<listcomp>) 3 0.000 0.000 0.000 0.000 rings.py:618(__pow__) 525 0.000 0.000 0.000 0.000 free_module.py:621(__contains__) 291 0.000 0.000 0.000 0.000 pushout.py:917(__ne__) 28 0.000 0.000 0.000 0.000 {method 'monomial' of 'sage.rings.polynomial.multi_polynomial_ring_base.MPolynomialRing_base' objects} 201 0.000 0.000 0.000 0.000 term_order.py:875(__copy) 117 0.000 0.000 0.000 0.000 {built-in method sage.rings.ring._is_Field} 582 0.000 0.000 0.000 0.000 category.py:521(<genexpr>) 3 0.000 0.000 0.000 0.000 free_module.py:5768(change_ring) 170 0.000 0.000 0.000 0.000 stream.py:719(__getitem__) 880 0.000 0.000 0.000 0.000 {method 'variable_name' of 'sage.structure.category_object.CategoryObject' objects} 1408 0.000 0.000 0.000 0.000 copy.py:107(_copy_immutable) 84 0.000 0.000 0.000 0.000 {method 'rich_compare' of 'sage.rings.polynomial.polydict.PolyDict' objects} 2034 0.000 0.000 0.000 0.000 {method 'denominator' of 'sage.rings.fraction_field_element.FractionFieldElement' objects} 2 0.000 0.000 0.000 0.000 infinite_polynomial_ring.py:816(_coerce_map_from_) 35 0.000 0.000 0.000 0.000 infinite_polynomial_ring.py:519(__init__) 2 0.000 0.000 0.000 0.000 pushout.py:4017(pushout) 471 0.000 0.000 0.000 0.000 {built-in method sage.arith.power.generic_power} 41 0.000 0.000 0.000 0.000 sf.py:886(_repr_) 1631 0.000 0.000 0.000 0.000 {method 'is_exact' of 'sage.rings.ring.Ring' objects} 28 0.000 0.000 0.000 0.000 infinite_polynomial_element.py:631(<listcomp>) 32 0.000 0.000 0.000 0.000 lazy_series_ring.py:2554(_monomial) 77 0.000 0.000 0.000 0.000 infinite_polynomial_element.py:608(<genexpr>) 713 0.000 0.000 0.000 0.000 infinite_polynomial_ring.py:1628(polynomial_ring) 28 0.000 0.000 0.000 0.000 verbose.py:116(verbose) 516 0.000 0.000 0.000 0.000 {built-in method sage.structure.coerce.py_scalar_to_element} 35 0.000 0.000 0.000 0.000 {method 'gens_dict' of 'sage.structure.category_object.CategoryObject' objects} 87 0.000 0.000 0.000 0.000 polynomial_element_generic.py:419(__normalize) 291 0.000 0.000 0.000 0.000 pushout.py:892(__eq__) 28 0.000 0.000 0.000 0.000 multi_polynomial_element.py:1500(<listcomp>) 4 0.000 0.000 0.000 0.000 {method 'matrix_from_columns' of 'sage.matrix.matrix1.Matrix' objects} 1843 0.000 0.000 0.000 0.000 {method 'isupper' of 'str' objects} 28 0.000 0.000 0.000 0.000 multi_polynomial_element.py:1634(variables) 7 0.000 0.000 0.000 0.000 sequence.py:78(Sequence) 42 0.000 0.000 0.000 0.000 matrix_space.py:92(get_matrix_class) 1 0.000 0.000 0.000 0.000 stream.py:1738(_good_cache) 28 0.000 0.000 0.000 0.000 timing.py:25(cputime) 4 0.000 0.000 0.000 0.000 sfa.py:1884(__getitem__) 4 0.000 0.000 0.000 0.000 pushout.py:4744(construction_tower) 644 0.000 0.000 0.000 0.000 rational_field.py:245(_repr_) 6 0.000 0.000 0.000 0.000 infinite_polynomial_ring.py:745(__repr__) 81 0.000 0.000 0.000 0.000 qqbar_decorators.py:93(<genexpr>) 1 0.000 0.000 0.000 0.000 stream.py:1699(_input_streams) 408 0.000 0.000 0.000 0.000 {method 'issubset' of 'set' objects} 35 0.000 0.000 0.000 0.000 infinite_polynomial_ring.py:413(__init__) 23 0.000 0.000 0.000 0.000 lazy_series.py:2845(__pow__) 483 0.000 0.000 0.000 0.000 {method 'is_exact' of 'sage.structure.parent.Parent' objects} 19 0.000 0.000 0.000 0.000 free_module.py:5423(_coerce_map_from_) 127 0.000 0.000 0.000 0.000 lazy_series.py:304(__init__) 108 0.000 0.000 0.000 0.000 polynomial_element_generic.py:547(degree) 123 0.000 0.000 0.000 0.000 indexed_generators.py:269(_parse_names) 201 0.000 0.000 0.000 0.000 {method 'copy' of 'dict' objects} 36 0.000 0.000 0.000 0.000 lazy_series.py:3216(<listcomp>) 53 0.000 0.000 0.000 0.000 free_module.py:982(degree) 6 0.000 0.000 0.000 0.000 lazy_series.py:3338(_div_) 26 0.000 0.000 0.000 0.000 category.py:425(__classcall__) 28 0.000 0.000 0.000 0.000 {method 'is_zero' of 'sage.structure.element.Element' objects} 18 0.000 0.000 0.000 0.000 free_module.py:8216(element_class) 87 0.000 0.000 0.000 0.000 polynomial_element_generic.py:421(<listcomp>) 97 0.000 0.000 0.000 0.000 {method 'split' of 'str' objects} 296 0.000 0.000 0.000 0.000 {method 'pop' of 'dict' objects} 7 0.000 0.000 0.000 0.000 {method 'transpose' of 'sage.matrix.matrix_sparse.Matrix_sparse' objects} 36 0.000 0.000 0.000 0.000 polynomial_element_generic.py:797(<dictcomp>) 18 0.000 0.000 0.000 0.000 category.py:2486(category) 28 0.000 0.000 0.000 0.000 {built-in method resource.getrusage} 183 0.000 0.000 0.000 0.000 partition.py:696(<genexpr>) 11 0.000 0.000 0.000 0.000 fraction_field.py:434(is_finite) 28 0.000 0.000 0.000 0.000 multi_polynomial_element.py:541(degrees) 8 0.000 0.000 0.000 0.000 polynomial_ring.py:651(construction) 36 0.000 0.000 0.000 0.000 polynomial_element_generic.py:425(__getitem__) 35 0.000 0.000 0.000 0.000 abc.py:117(__instancecheck__) 28 0.000 0.000 0.000 0.000 multi_polynomial_element.py:1658(<listcomp>) 6 0.000 0.000 0.000 0.000 lazy_series.py:1040(__bool__) 246 0.000 0.000 0.000 0.000 rational_field.py:256(_repr_option) 11 0.000 0.000 0.000 0.000 vector_spaces.py:41(__classcall_private__) 21 0.000 0.000 0.000 0.000 multi_polynomial_sequence.py:305(<lambda>) 107 0.000 0.000 0.000 0.000 indexed_generators.py:201(print_options) 98 0.000 0.000 0.000 0.000 matrix_space.py:2341(ncols) 14 0.000 0.000 0.000 0.000 sequence.py:398(__init__) 7 0.000 0.000 0.000 0.000 multi_polynomial_sequence.py:386(__init__) 285 0.000 0.000 0.000 0.000 {method 'category' of 'sage.structure.parent.Parent' objects} 36 0.000 0.000 0.000 0.000 polynomial_element_generic.py:198(valuation) 36 0.000 0.000 0.000 0.000 polynomial_element_generic.py:113(<dictcomp>) 13 0.000 0.000 0.000 0.000 global_options.py:1158(__getitem__) 70 0.000 0.000 0.000 0.000 infinite_polynomial_ring.py:428(<genexpr>) 93 0.000 0.000 0.000 0.000 {built-in method builtins.min} 31 0.000 0.000 0.000 0.000 free_module.py:228(create_key) 41 0.000 0.000 0.000 0.000 lazy_series_ring.py:2822(<listcomp>) 98 0.000 0.000 0.000 0.000 matrix_space.py:2353(nrows) 296 0.000 0.000 0.000 0.000 {method 'base' of 'sage.structure.category_object.CategoryObject' objects} 28 0.000 0.000 0.000 0.000 infinite_polynomial_element.py:1250(__iter__) 35 0.000 0.000 0.000 0.000 {built-in method _abc._abc_instancecheck} 11 0.000 0.000 0.000 0.000 modules_with_basis.py:1066(is_finite) 4 0.000 0.000 0.000 0.000 rational_field.py:308(construction) 123 0.000 0.000 0.000 0.000 sfa.py:2426(prefix) 95 0.000 0.000 0.000 0.000 sfa.py:444(is_field) 3 0.000 0.000 0.000 0.000 free_module.py:1097(zero_vector) 99 0.000 0.000 0.000 0.000 stream.py:146(__init__) 97 0.000 0.000 0.000 0.000 {method 'lstrip' of 'str' objects} 4 0.000 0.000 0.000 0.000 sfa.py:3054(construction) 1 0.000 0.000 0.000 0.000 global_options.py:581(__radd__) 7 0.000 0.000 0.000 0.000 sequence.py:238(<listcomp>) 28 0.000 0.000 0.000 0.000 {method 'max_exp' of 'sage.rings.polynomial.polydict.PolyDict' objects} 4 0.000 0.000 0.000 0.000 fraction_field.py:746(construction) 8 0.000 0.000 0.000 0.000 pushout.py:2430(__init__) 6 0.000 0.000 0.000 0.000 {method 'fraction_field' of 'sage.rings.ring.CommutativeRing' objects} 71 0.000 0.000 0.000 0.000 stream.py:769(order) 123 0.000 0.000 0.000 0.000 {built-in method builtins.callable} 23 0.000 0.000 0.000 0.000 free_module.py:1184(__richcmp__) 123 0.000 0.000 0.000 0.000 indexed_generators.py:159(<lambda>) 4 0.000 0.000 0.000 0.000 infinite_polynomial_ring.py:1564(construction) 50 0.000 0.000 0.000 0.000 free_module.py:2949(coordinate_ring) 2 0.000 0.000 0.000 0.000 category.py:682(__contains__) 1 0.000 0.000 0.000 0.000 stream.py:1547(__del__) 4 0.000 0.000 0.000 0.000 sfa.py:6488(__init__) 16 0.000 0.000 0.000 0.000 combinat.py:1241(__lt__) 49 0.000 0.000 0.000 0.000 {method 'gen' of 'sage.rings.polynomial.multi_polynomial_ring_base.MPolynomialRing_base' objects} 29 0.000 0.000 0.000 0.000 lazy_series.py:5975(<listcomp>) 88 0.000 0.000 0.000 0.000 {method 'append' of 'list' objects} 4 0.000 0.000 0.000 0.000 integral_domains.py:45(__contains__) 45 0.000 0.000 0.000 0.000 sfa.py:2857(basis_name) 62 0.000 0.000 0.000 0.000 stream.py:1733(<genexpr>) 1 0.000 0.000 0.000 0.000 stream.py:1030(input_streams) 4 0.000 0.000 0.000 0.000 stream.py:2079(<listcomp>) 2 0.000 0.000 0.000 0.000 category.py:3023(_subcategory_hook_) 1 0.000 0.000 0.000 0.000 stream.py:1055(<listcomp>) 3 0.000 0.000 0.000 0.000 fields.py:803(inverse_of_unit) 4 0.000 0.000 0.000 0.000 pushout.py:1265(__init__) 13 0.000 0.000 0.000 0.000 global_options.py:1515(_match_option) 5 0.000 0.000 0.000 0.000 non_negative_integers.py:172(__iter__) 28 0.000 0.000 0.000 0.000 {method 'nonzero_positions' of 'sage.rings.polynomial.polydict.ETuple' objects} 4 0.000 0.000 0.000 0.000 infinite_polynomial_ring.py:1311(is_integral_domain) 6 0.000 0.000 0.000 0.000 category.py:3044(<genexpr>) 9 0.000 0.000 0.000 0.000 stream.py:2549(__getitem__) 42 0.000 0.000 0.000 0.000 matrix_space.py:2088(is_sparse) 1 0.000 0.000 0.000 0.000 stream.py:2197(is_uninitialized) 28 0.000 0.000 0.000 0.000 stream.py:242(is_uninitialized) 6 0.000 0.000 0.000 0.000 multi_polynomial_ring.py:948(is_field) 20 0.000 0.000 0.000 0.000 stream.py:2078(<genexpr>) 8 0.000 0.000 0.000 0.000 stream.py:2442(input_streams) 28 0.000 0.000 0.000 0.000 {method 'fraction_field' of 'sage.rings.ring.Field' objects} 18 0.000 0.000 0.000 0.000 category.py:1807(or_subcategory) 12 0.000 0.000 0.000 0.000 pushout.py:4443(<genexpr>) 1 0.000 0.000 0.000 0.000 free_module.py:1118(zero) 14 0.000 0.000 0.000 0.000 sets_cat.py:1895(is_finite) 1 0.000 0.000 0.000 0.000 stream.py:1586(input_streams) 10 0.000 0.000 0.000 0.000 {method 'pop' of 'list' objects} 11 0.000 0.000 0.000 0.000 integral_domains.py:100(is_integral_domain) 7 0.000 0.000 0.000 0.000 multi_polynomial_sequence.py:447(ring) 7 0.000 0.000 0.000 0.000 sequence.py:699(universe) 14 0.000 0.000 0.000 0.000 {method 'extend' of 'list' objects} 11 0.000 0.000 0.000 0.000 fraction_field.py:423(is_field) 10 0.000 0.000 0.000 0.000 {method 'nrows' of 'sage.matrix.matrix0.Matrix' objects} 6 0.000 0.000 0.000 0.000 infinite_polynomial_ring.py:1131(is_field) 2 0.000 0.000 0.000 0.000 pushout.py:4430(<listcomp>) 2 0.000 0.000 0.000 0.000 unique_factorization_domains.py:64(__contains__) 3 0.000 0.000 0.000 0.000 lazy_series.py:5964(<genexpr>) 6 0.000 0.000 0.000 0.000 multi_polynomial_ring.py:945(is_integral_domain) 6 0.000 0.000 0.000 0.000 {method 'is_prime_field' of 'sage.rings.ring.Ring' objects} 9 0.000 0.000 0.000 0.000 {method 'values' of 'dict' objects} 3 0.000 0.000 0.000 0.000 {method 'is_field' of 'sage.rings.integer_ring.IntegerRing_class' objects} 6 0.000 0.000 0.000 0.000 free_module.py:998(is_sparse) 2 0.000 0.000 0.000 0.000 pushout.py:4431(<listcomp>) 3 0.000 0.000 0.000 0.000 free_module.py:3308(rank) 2 0.000 0.000 0.000 0.000 polynomial_ring.py:555(_implementation_names_impl) 4 0.000 0.000 0.000 0.000 sets_cat.py:1451(construction) 1 0.000 0.000 0.000 0.000 stream.py:4958(initial) 4 0.000 0.000 0.000 0.000 {method 'find' of 'str' objects} 2 0.000 0.000 0.000 0.000 polynomial_ring.py:1295(is_field) 1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects} 2 0.000 0.000 0.000 0.000 {method 'replace' of 'str' objects} 1 0.000 0.000 0.000 0.000 {method 'set_immutable' of 'sage.structure.element.ModuleElementWithMutability' objects} On Sunday 3 November 2024 at 21:57:05 UTC+1 Martin R wrote: > I think I see things slightly clearer now. One problem is, that, by > design, we successively reduce to polynomial rings with fewer generators. > More precisely, MPolynomial.gcd converts the input to a univariate > polynomial in one of the generators, and > UniqueFactorizationDomains.ParentMethods._gcd_univariate_polynomial then > relies on the existence of a gcd for the new base ring. > > To do this, the new base ring, i.e., the ring with one fewer generator, > must be constructed, and this is rather expensive. If I understand > correctly, almost all the time is spent there. This is done in > `MPolynomial.polynomial` using `S = PolynomialRing(R.base_ring(), Z)` > > So, the questions are: > 1. is there a (much) faster way to construct the univariate polynomial > ring? I tried to do S = R.__class__(R.base_ring(), len(Z), [str(z) for z > in Z], R.term_order()) when Z has at least two variables (because of the > difference between univariate and multivariate polynomial rings) but to my > surprise this was actually slower. > 2. can we bypass the construction of polynomial rings entirely? > > On Sunday 3 November 2024 at 17:11:23 UTC+1 Martin R wrote: > >> Possibly the problem is that MPolynomial.gcd calls >> UniqueFactorizationDomains.ParentMethods._gcd_univariate_polynomial, which >> recurses on MPolynomial.gcd, but the setup done by MPolynomial.gcd is >> possibly not cheap. >> >> On Sunday 3 November 2024 at 12:31:44 UTC+1 Martin R wrote: >> >>> Are the following timings to be expected? >>> >>> sage: R = SymmetricFunctions(QQ).h().fraction_field() >>> sage: P = PolynomialRing(R, 200, "x") >>> sage: e = P.gen(199); e >>> x199 >>> sage: %time e.gcd(e) >>> CPU times: user 41.1 s, sys: 2.24 s, total: 43.4 s >>> Wall time: 43.5 s >>> x199 >>> >>> sage: R = QQ >>> sage: P = PolynomialRing(R, 200, "x") >>> sage: e = P.gen(199); e >>> x199 >>> sage: %time e.gcd(e) >>> CPU times: user 41 µs, sys: 0 ns, total: 41 µs >>> Wall time: 47 µs >>> x199 >>> >>> sage: R = QQbar >>> sage: P = PolynomialRing(R, 200, "x") >>> sage: e = P.gen(199); e >>> x199 >>> sage: %time e.gcd(e) >>> CPU times: user 3.02 s, sys: 183 ms, total: 3.2 s >>> Wall time: 3.21 s >>> x199 >>> >> -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To view this discussion visit https://groups.google.com/d/msgid/sage-devel/981a9825-b154-498a-b4f3-620bdb18bc91n%40googlegroups.com.