[Patches] [ python-Patches-416953 ] Speed up ASCII decoding
noreply@sourceforge.net
noreply@sourceforge.net
Wed, 18 Apr 2001 05:51:03 -0700
Patches item #416953, was updated on 2001-04-17 22:37
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=416953&group_id=5470
Category: core (C code)
Group: None
>Status: Closed
>Resolution: Accepted
Priority: 5
Submitted By: Martin v. Löwis (loewis)
>Assigned to: Nobody/Anonymous (nobody)
Summary: Speed up ASCII decoding
Initial Comment:
In code that supports both byte and unicode strings,
mixing unicode strings with plain character constants
is frequent. E.g. both sre_compile and xmlproc look for
specific characters in an input string. Every usage of
such a character requires default decoding, which will
create a temporary Unicode object.
This patch caches Unicode objects that represent ASCII
characters. On the benchmark
import time
u = u""
t=time.time()
for i in xrange(1000000):
u+"("
print time.time()-t
it shows a 10% speed-up.
----------------------------------------------------------------------
>Comment By: Martin v. Löwis (loewis)
Date: 2001-04-18 05:51
Message:
Logged In: YES
user_id=21627
Committed as 2.83 of unicodeobject.c, with the requested
addition of init/fini code.
----------------------------------------------------------------------
Comment By: M.-A. Lemburg (lemburg)
Date: 2001-04-18 01:54
Message:
Logged In: YES
user_id=38388
I knew this would come one day :-)
The patch looks OK, but please also add proper init and
finalize code so that unicode_ascii[] gets cleared up
properly when the interpreter shuts down (this is important
for uses of Python in e.g. mod_snake).
----------------------------------------------------------------------
Comment By: Martin v. Löwis (loewis)
Date: 2001-04-17 23:04
Message:
Logged In: YES
user_id=21627
Attach patch.
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=416953&group_id=5470