Opened 11 years ago

Closed 9 years ago

#10834 closed enhancement (fixed)

faster creation of an ETuple from a list or tuple

Reported by: pernici Owned by: AlexGhitza
Priority: major Milestone: sage-5.8
Component: algebra Keywords: days45
Cc: Merged in: sage-5.8.beta0
Authors: Mario Pernici Reviewers: Travis Scrimshaw
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description

faster creation of an ETuple from a list or tuple

Attachments (1)

trac_10834_etuple.patch (1.5 KB) - added by pernici 11 years ago.

Download all attachments as: .zip

Change History (6)

Changed 11 years ago by pernici

comment:1 Changed 11 years ago by pernici

With trac_10834_etuple.patch the creation of an ETuple from a list or tuple is faster

main is Sage-4.6 unpatched; run with processor Intel Core i7 2.80GHz

main
sage: from sage.rings.polynomial.polydict import ETuple
sage: a = [map(int,[i,1,-5, 3, 1,0]) for i in range(100)]
sage: %timeit map(ETuple,a)
625 loops, best of 3: 130 µs per loop

patch
625 loops, best of 3: 21.5 µs per loop

The multi_polynomial_libsingular exponent method becomes faster; here is a benchmark taken from ticket #7587

main
sage: R = PolynomialRing(QQ,100,'x')
sage: p = R.random_element(degree=50,terms=50)
sage: timeit('p.exponents()')
625 loops, best of 3: 595 µs per loop
sage: timeit('p.exponents(as_ETuples=False)')
625 loops, best of 3: 78.3 µs per loop

patch
sage: R = PolynomialRing(QQ,100,'x')
sage: p = R.random_element(degree=50,terms=50)
sage: timeit('p.exponents()')
625 loops, best of 3: 119 µs per loop
sage: timeit('p.exponents(as_ETuples=False)')
625 loops, best of 3: 70.9 µs per loop

comment:2 Changed 9 years ago by tscrim

  • Reviewers set to Travis Scrimshaw
  • Status changed from new to needs_review

I believe this patch is ready for review so I'm marking it as such, and I'm starting the review for it.

comment:3 Changed 9 years ago by tscrim

  • Keywords days45 added
  • Status changed from needs_review to positive_review

Looks good to me.

Before patch (running 5.7.beta3):

sage: %timeit ETuple([5,2,2,1])
100000 loops, best of 3: 6.4 us per loop
sage: %timeit ETuple([5,2,2,1]*20)
10000 loops, best of 3: 54.8 us per loop
sage: L = [5,2,2,1]*10000         
sage: %timeit ETuple(L)           
10 loops, best of 3: 26 ms per loop
sage: %timeit ETuple(L)
10 loops, best of 3: 24.2 ms per loop

After patch:

sage: %timeit ETuple([5,2,2,1])
100000 loops, best of 3: 3.1 us per loop
sage: %timeit ETuple([5,2,2,1]*20)
10000 loops, best of 3: 26.9 us per loop
sage: L = [5,2,2,1]*10000
sage: %timeit ETuple(L)           
100 loops, best of 3: 5.97 ms per loop
sage: %timeit ETuple(L)
100 loops, best of 3: 6.23 ms per loop

comment:4 Changed 9 years ago by jdemeyer

  • Authors changed from mario pernici to Mario Pernici
  • Milestone changed from sage-5.7 to sage-5.8

comment:5 Changed 9 years ago by jdemeyer

  • Merged in set to sage-5.8.beta0
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.