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

[fixed by #4000] x^2 for x over QQ is really frickin' slow compared to over ZZ (nearly factor of 100!!) #6063

Closed
williamstein opened this issue May 18, 2009 · 5 comments

Comments

@williamstein
Copy link
Contributor

wstein@sage:~$ sage
----------------------------------------------------------------------
| Sage Version 3.4.1, Release Date: 2009-04-21                       |
| Type notebook() for the GUI, and license() for information.        |
----------------------------------------------------------------------
sage: R.<x> = ZZ[]
sage: timeit('x^2')
625 loops, best of 3: 1.4 µs per loop
sage: R.<x> = QQ[]
sage: timeit('x^2')
625 loops, best of 3: 118 µs per loop
sage: %prun x**2
         34 function calls in 0.001 CPU seconds

   Ordered by: internal time

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
        1    0.000    0.000    0.001    0.001 <string>:1(<module>)
        1    0.000    0.000    0.000    0.000 polynomial_element_generic.py:590(__init__)
        4    0.000    0.000    0.000    0.000 polynomial_element_generic.py:656(__getitem__)
        3    0.000    0.000    0.000    0.000 {method 'poldegree' of 'sage.libs.pari.gen.gen' objects}
        3    0.000    0.000    0.000    0.000 polynomial_element_generic.py:874(degree)
        2    0.000    0.000    0.000    0.000 {method 'Polrev' of 'sage.libs.pari.gen.gen' objects}
        1    0.000    0.000    0.000    0.000 polynomial_ring.py:211(_element_constructor_)
        1    0.000    0.000    0.000    0.000 polynomial_ring.py:741(gen)
        9    0.000    0.000    0.000    0.000 {isinstance}
        3    0.000    0.000    0.000    0.000 {max}
        1    0.000    0.000    0.000    0.000 {hasattr}
        1    0.000    0.000    0.000    0.000 polynomial_ring.py:810(is_sparse)
        1    0.000    0.000    0.000    0.000 {method 'type' of 'sage.libs.pari.gen.gen' objects}
        1    0.000    0.000    0.000    0.000 {len}
        1    0.000    0.000    0.000    0.000 {sage.rings.fraction_field_element.is_FractionFieldElement}
        1    0.000    0.000    0.000    0.000 {method 'disable' of '_lsprof.Profiler' objects}

sage: R.<x> = ZZ[]
sage: %prun x**2
         3 function calls in 0.000 CPU seconds

   Ordered by: internal time

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
        1    0.000    0.000    0.000    0.000 <string>:1(<module>)
        1    0.000    0.000    0.000    0.000 polynomial_ring.py:741(gen)
        1    0.000    0.000    0.000    0.000 {method 'disable' of '_lsprof.Profiler' objects}

Component: basic arithmetic

Reviewer: David Loeffler

Issue created by migration from https://trac.sagemath.org/ticket/6063

@aghitza
Copy link

aghitza commented Jul 13, 2009

comment:1

See also #4000, which might be the best way to fix this.

@williamstein
Copy link
Contributor Author

comment:2

This is because polynomials over QQ are still pure Python. This is an enhancement, not a bug.

@sagetrac-jrp
Copy link
Mannequin

sagetrac-jrp mannequin commented Jan 21, 2011

comment:3

This appears to be fixed now - the QQ one is even slightly faster.

@loefflerd
Copy link
Mannequin

loefflerd mannequin commented Jan 22, 2011

comment:4

Yes, this is fixed. Release manager: please close this ticket.

@loefflerd loefflerd mannequin added the s: needs review label Jan 22, 2011
@loefflerd loefflerd mannequin changed the title x^2 for x over QQ is really frickin' slow compared to over ZZ (nearly factor of 100!!) [fixed by #4000] x^2 for x over QQ is really frickin' slow compared to over ZZ (nearly factor of 100!!) Jan 22, 2011
@jdemeyer
Copy link

Reviewer: David Loeffler

@jdemeyer jdemeyer removed this from the sage-4.6.2 milestone Jan 22, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants