#14585: Make lazy_format and lazy_string faster
-------------------------------------+-------------------------------------
Reporter: SimonKing | Owner: robertwb
Type: defect | Status: needs_work
Priority: major | Milestone: sage-6.4
Component: coercion | Resolution:
Keywords: | Merged in:
Authors: Simon King | Reviewers:
Report Upstream: N/A | Work issues:
Branch: | Commit:
u/SimonKing/Make_lazy_format_faster| af6750bdb2ff7d8a6b234cf3f021e2f603030be6
Dependencies: | Stopgaps:
-------------------------------------+-------------------------------------
Comment (by SimonKing):
Without the !CallObject, we get
{{{
sage: from sage.misc.lazy_string import lazy_string
sage: f = lambda x: "laziness" + repr(x)
sage: s = lazy_string(f, 5)
sage: %timeit str(s)
The slowest run took 13.06 times longer than the fastest. This could mean
that an intermediate result is being cached
1000000 loops, best of 3: 1.53 µs per loop
sage: s = lazy_string("This is %s", ZZ)
sage: %timeit str(s)
The slowest run took 8.76 times longer than the fastest. This could mean
that an intermediate result is being cached
100000 loops, best of 3: 2.29 µs per loop
}}}
With the !CallObject, we get
{{{
sage: from sage.misc.lazy_string import lazy_string
sage: f = lambda x: "laziness" + repr(x)
sage: s = lazy_string(f, 5)
sage: %timeit str(s)
The slowest run took 15.19 times longer than the fastest. This could mean
that an intermediate result is being cached
1000000 loops, best of 3: 1.59 µs per loop
sage: s = lazy_string("This is %s", ZZ)
sage: %timeit str(s)
The slowest run took 10.33 times longer than the fastest. This could mean
that an intermediate result is being cached
100000 loops, best of 3: 2.42 µs per loop
}}}
So, in contrast to what is claimed in comment:21, I don't see an
improvement. Should we revert it? Or can you provide an example where the
change really matters?
----
New commits:
||[http://git.sagemath.org/sage.git/commit/?id=af6750bdb2ff7d8a6b234cf3f021e2f603030be6
af6750b]||{{{Use PyObject_Call, to avoid *args,**kwds}}}||
--
Ticket URL: <http://trac.sagemath.org/ticket/14585#comment:43>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.