[Patches] [ python-Patches-1511853 ] Speed up decimal object construction

SourceForge.net noreply at sourceforge.net
Sat Jun 24 19:19:58 CEST 2006


Patches item #1511853, was opened at 2006-06-25 03:19
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1511853&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Library (Lib)
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Submitted By: Nick Coghlan (ncoghlan)
Assigned to: Raymond Hettinger (rhettinger)
Summary: Speed up decimal object construction

Initial Comment:
The numerical programming discussion on python-dev
reminded me to try out the new profiler on the decimal
module.

It showed more than a quarter of the execution time for
the unit tests was being spent in decimal.__new__ and
in doing isinstance checks.

This patch adds fast paths that avoids the isinstance
checks when dealing solely with builtin types. It also
caches a couple of incidental values when checking for
special Decimal values during construction from a
string instead of making the same function calls twice.

However, while the speed benefit was significant under
profiling (saving around 15 seconds on the 60 second
runtime of the decimal unit tests), it was far less
impressive under normal operation (saving around 0.5
seconds on the 12.5 second run time of the unit tests,
and around 5 seconds on the 530+ seconds needed to run
the full telco.py benchmark).

So it's definitely faster, but the real magnitude of
the benefit is still an open question.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1511853&group_id=5470


More information about the Patches mailing list