Le lundi 07 mars 2011 à 10:05 +0100, Éric Araujo a écrit :
> Hi,
> 
> > Author: victor.stinner
> > Date: Wed Mar  2 02:03:14 2011
> > New Revision: 88709
> > Log: Issue #8923: cache str.encode() result
> > 
> > When a string is encoded to UTF-8 in strict mode, the result is cached into 
> > the
> > object. Examples: str.encode(), str.encode('utf-8'), 
> > PyUnicode_AsUTF8String()
> > and PyUnicode_AsEncodedString(unicode, "utf-8", NULL).
> 
> I don’t really understand this message (especially “cached into the
> object”) :)  Maybe in the Misc/NEWS entry you could also add a line to
> explain to users the reason/goal/benefit of this change?

If you call str.encode() twice: the first call stores the result in a
cache, and the second call just reuse the cache. The benefit is that the
second call is much faster.

The cache is an internal attribute of the Unicode object (str type).

Do you have a suggestion to rephrase the Misc/NEWS entry?

PS: The Unicode object did already use this cache, but not always (eg.
not for str.encode() or str.encode('utf-8')).

Victor

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to