[Zope-CVS] CVS: Products/ZCTextIndex - Index.py:1.1.2.30
Tim Peters
tim.one@comcast.net
Sun, 5 May 2002 21:14:44 -0400
Update of /cvs-repository/Products/ZCTextIndex
In directory cvs.zope.org:/tmp/cvs-serv18382
Modified Files:
Tag: TextIndexDS9-branch
Index.py
Log Message:
scaled_int(): Speed the rounding. This function is called in
Index.search()'s innermost loop, and I noticed that it consumed about
0.4 seconds *just* to call scaled_int 55,000 times.
=== Products/ZCTextIndex/Index.py 1.1.2.29 => 1.1.2.30 ===
def scaled_int(f, scale=SCALE_FACTOR):
- return int(round(f * scale))
+ # We expect only positive inputs, so "add a half and chop" is the
+ # same as round(). Surprising, calling round() is significantly more
+ # expensive.
+ return int(f * scale + 0.5)
class Index:
__implements__ = IIndex