[Zope3-dev] string agnostic page templates, again

Fred Drake fdrake at gmail.com
Wed Sep 8 15:34:08 EDT 2004


On Wed, 8 Sep 2004 15:22:24 -0400, Paul Winkler <pw_lists at slinkp.com> wrote:
> On my system, adding 'ascii' as the second arg seems to add about
> 3% to the run time independent of the size of the first argument,
> plus some fixed overhead that is significant with really small
> inputs:

Poking around a bit more, there's a C implementation of an str decoder
that ensures only ASCII is present.  It can be loaded using:

import codecs

ascii_decoder = codecs.lookup("ascii")[0]

This will return if the input is all ASCII, or raise
UnicodeDecodeError if not.  Using a saved value for ascii_decoder will
probably be faster than using unicode(s) or unicode(s, "ascii").


  -Fred

-- 
Fred L. Drake, Jr.    <fdrake at gmail.com>
Zope Corporation


More information about the Zope3-dev mailing list