Opened 12 years ago

Closed 10 years ago

#6063 closed enhancement (duplicate)

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

Reported by: was Owned by: somebody
Priority: major Milestone: sage-duplicate/invalid/wontfix
Component: basic arithmetic Keywords:
Cc: Merged in:
Authors: Reviewers: David Loeffler
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description

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}

Change History (6)

comment:1 Changed 12 years ago by AlexGhitza

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

comment:2 Changed 11 years ago by was

  • Report Upstream set to N/A
  • Type changed from defect to enhancement

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

comment:3 Changed 10 years ago by jrp

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

comment:4 Changed 10 years ago by davidloeffler

  • Status changed from new to needs_review
  • Summary changed from x^2 for x over QQ is really frickin' slow compared to over ZZ (nearly factor of 100!!) to [fixed by #4000] x^2 for x over QQ is really frickin' slow compared to over ZZ (nearly factor of 100!!)

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

comment:5 Changed 10 years ago by davidloeffler

  • Status changed from needs_review to positive_review

comment:6 Changed 10 years ago by jdemeyer

  • Milestone changed from sage-4.6.2 to sage-duplicate/invalid/wontfix
  • Resolution set to duplicate
  • Reviewers set to David Loeffler
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.