[Python-bugs-list] [ python-Bugs-780807 ] time.strptime() 1, 200 times slower in python2.3

SourceForge.net noreply at sourceforge.net
Thu Aug 7 20:01:55 EDT 2003


Bugs item #780807, was opened at 2003-07-31 05:17
Message generated for change (Comment added) made by bcannon
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=780807&group_id=5470

Category: Python Library
Group: Python 2.3
>Status: Closed
>Resolution: Fixed
Priority: 4
Submitted By: Malte John (drmalte)
Assigned to: Brett Cannon (bcannon)
Summary: time.strptime() 1,200 times slower in python2.3

Initial Comment:
time.strptime() ist about 1,200 (onethousand and
twohundred) times slower in 2.3 than in 2.2! (1m:48.45s
vs. 0.09s) This is caused by the pure python
implementation. 

Fix:
I simply repaced the function time_strptime(PyObject
*self, PyObject *args) from
Python-2.3/Modules/timemodule.c with the function from
python 2.2. 
Maybe 'configure' should check for existence of the
strptime() function on the target system and use it, if
available?

Regards,
Malte

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

>Comment By: Brett Cannon (bcannon)
Date: 2003-08-07 19:01

Message:
Logged In: YES 
user_id=357491

OK, the caching has been backported to 2.3.1 so the performance 
should be close to what 2.4 has.  Closing this bug report.

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

Comment By: Brett Cannon (bcannon)
Date: 2003-08-05 11:22

Message:
Logged In: YES 
user_id=357491

That sounds reasonable considering you are having to go through 
the C API for the strings and I am using regexes instead of simple 
split-on-whitespace/compare parsing like strptime in C pushes for 
(perk is that Python's strptime can parse %Y%m%d since the 
separation of whitespace for items is not required).

Now I just need to see if I should backport to 2.3.1 .

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

Comment By: Malte John (drmalte)
Date: 2003-08-05 06:46

Message:
Logged In: YES 
user_id=834648

Hi,
I pulled out the brand new version 1.24 wih reintroduced
caching.
Speedup is is about 400 times :) so it is only three times
slower than the system strptime in my testloop ( ~6000
lines/s vs. 16200 lines/s )

Thanks a lot!
Malte


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

Comment By: Brett Cannon (bcannon)
Date: 2003-08-04 09:36

Message:
Logged In: YES 
user_id=357491

Raymond is talking about version 1.21 .  That was the last version 
with caching.

I realize that strptime is no longer a speed demon for those 
platforms that have a C version, but now everyone has a version 
that is consistent which I think is worth the slowdown.

But there still might be hope for a speedup.  There is a chance 
that I will be allowed to reintroduce the caching code for 2.3.1 .  If 
that happens performance will pick up significantly.  If not you will 
have to wait until 2.4 .

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

Comment By: Malte John (drmalte)
Date: 2003-08-03 10:45

Message:
Logged In: YES 
user_id=834648

Thanks for the hint!
I pulled out _strptimy.py Version 1.23 which is identical to
the version in the Python-2.3.tgz I used. :(
Here is the output of tar -ztvf 
...
-rw-rw-r-- barry/barry   20933 2003-07-24 22:02:28
Python-2.3/Lib/_strptime.py
...

Regards
Malte

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

Comment By: Raymond Hettinger (rhettinger)
Date: 2003-08-02 01:53

Message:
Logged In: YES 
user_id=80475

It would be interesting for you to pull down the CVS version 
from two weeks ago and re-run your timings.  The caching 
code was removed at the end because it was a temporary 
suspect on a bug-hunt just days before the release.

Note, the whole purpose of the pure python version was to 
avoid the non-portable differences between strptime() 
implementations on various target systems.

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

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



More information about the Python-bugs-list mailing list