Ticket #3387 (closed defect: fixed)

Opened 5 years ago

Last modified 5 years ago

[with patch; with positive review] unacceptably slow conversion of rationals from pari to Rational

Reported by: dmharvey Owned by: was
Priority: major Milestone: sage-3.0.3
Component: algebra Keywords:
Cc: Work issues:
Report Upstream: Reviewers:
Authors: Merged in:
Dependencies: Stopgaps:

Description

sage: x = (2^1000000 - 1) / (2^1000000)
sage: time y = pari(x)
CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
Wall time: 0.00
sage: time z = Rational(y)
CPU times: user 11.30 s, sys: 0.02 s, total: 11.32 s
Wall time: 11.33

Attachments

sage-3387.patch Download (1.9 KB) - added by was 5 years ago.

Change History

comment:1 Changed 5 years ago by was

  • Owner changed from tbd to was

Changed 5 years ago by was

comment:2 Changed 5 years ago by was

  • Summary changed from unacceptably slow conversion of rationals from pari to Rational to [with patch; needs review] unacceptably slow conversion of rationals from pari to Rational
  • Milestone set to sage-3.0.3

with this patch the situation is better:

sage: x = pari('(2^1000000 - 1) / (2^1000000)')
sage: time y = Rational(x)
CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
Wall time: 0.00 s
sage: timeit('Rational(x)')
625 loops, best of 3: 858 µs per loop
sage: Rational(pari('x^2+1'))
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)

/Users/was/Desktop/movies/<ipython console> in <module>()

/Users/was/Desktop/movies/rational.pyx in sage.rings.rational.Rational.__init__ (sage/rings/rational.c:3321)()

/Users/was/Desktop/movies/rational.pyx in sage.rings.rational.Rational.__set_value (sage/rings/rational.c:4386)()

/Users/was/Desktop/movies/integer.pyx in sage.rings.integer.Integer.__init__ (sage/rings/integer.c:5183)()

/Users/was/Desktop/movies/gen.pyx in sage.libs.pari.gen.gen.__hex__ (sage/libs/pari/gen.c:5096)()

TypeError: gen must be of PARI type t_INT

comment:3 Changed 5 years ago by gfurnish

  • Summary changed from [with patch; needs review] unacceptably slow conversion of rationals from pari to Rational to [with patch; with positive review] unacceptably slow conversion of rationals from pari to Rational

Doctests pass, code looks fine.

comment:4 Changed 5 years ago by mabshoff

  • Status changed from new to closed
  • Resolution set to fixed

Merged in Sage 3.0.3.alpha2

Note: See TracTickets for help on using tickets.