[Patches] [ python-Patches-549375 ] Compromise PyUnicode_EncodeUTF8
noreply@sourceforge.net
noreply@sourceforge.net
Sat, 27 Apr 2002 07:53:16 -0700
Patches item #549375, was opened at 2002-04-27 04:35
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=549375&group_id=5470
Category: Core (C code)
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Tim Peters (tim_one)
Assigned to: M.-A. Lemburg (lemburg)
Summary: Compromise PyUnicode_EncodeUTF8
Initial Comment:
This combines various ideas from Python-Dev. It
overallocates, but:
1) For short strings it does the conversion into a
stack buffer, and allocates exactly as much string
space as it turns out it needs at the end. So it
should be faster, but not waste any small-block memory.
2) For long strings it knows it's going to end up in
the system malloc/realloc, so it asks for the maximum
possibly needed at the start, returning the excess
untouched at the end. This gets rid of all the
embedded "but did I really get enough memory yet?"
tests and reallocations.
----------------------------------------------------------------------
>Comment By: M.-A. Lemburg (lemburg)
Date: 2002-04-27 14:53
Message:
Logged In: YES
user_id=38388
Cool. I like it.
You better make sure the stack buffer doesn't overrun though
-- I've only skimmed the implementation, but would suggest
to an explicit test for this which is not only executed in
the debug build.
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=549375&group_id=5470