Quickest marshal.loads from unicode?
giles_brown at hotmail.com
Fri Feb 21 10:18:40 CET 2003
How can the I take the result of a marshal.dumps call and decode
into a unicode string so that the conversion back to a marshal.loads
compatible string is as quick as possible?
I have an application that uses a large number of Python code
that are expressions. I have to pre-process these fragments (using the
compiler module). For the number of expressions I have this can take
quite a long time.
I'd like to pre-compile the expressions and store them in an MS Access
database (because the rest of the application uses an MS Access
database.) It looks like an MS Access Memo field is most suited, but
the win32com wrapper for the memo field takes and gives a unicode
string. I don't care if the pre-compilation is a bit time consuming,
but the decoding + marshal.loads needs to be nippy.
I have googled for guidance on how to fit a binary data square peg
into a unicode string round hole.
Found swathes of python dev discussings on uses of
'raw-unicode-escape' vs 'utf-8' but couldn't find an answer that I
understood as definitive.
I have also tried doing a base64 encoding before I do a straight
".decode('ascii')", but unfortunately because this in a performance
sensitive part of the app (i.e. its done lots of times at start-up) it
seems to slow down the performance a fair bit.
Tips and suggestions appreciated,
More information about the Python-list