[Python-checkins] python/dist/src/Lib/email Generator.py,1.16,1.17

M.-A. Lemburg mal@lemburg.com
Mon, 14 Oct 2002 18:04:27 +0200


bwarsaw@users.sourceforge.net wrote:
> + def _is8bitstring(s):
> +     if isinstance(s, StringType):
> +         try:
> +             unicode(s, 'us-ascii')

Note that 'ascii' will be faster since there are short-cuts
in the C code which map this directly to the ASCII codec.

> +         except UnicodeError:
> +             return True
> +     return False
> + 

Since this kind of function occurs quite often in string
related code, wouldn't be better to code it in C and
publish it through e.g. the _codecs module ?!

-- 
Marc-Andre Lemburg
CEO eGenix.com Software GmbH
_______________________________________________________________________
eGenix.com -- Makers of the Python mx Extensions: mxDateTime,mxODBC,...
Python Consulting:                               http://www.egenix.com/
Python Software:                    http://www.egenix.com/files/python/