[Zope3-dev] RE: [Zope3-checkins] CVS:
Zope3/src/datetime- __init__.py:NONE_datetime.py:NONE doc.txt:NONE
Tim Peters
tim at zope.com
Thu Nov 6 12:09:41 EST 2003
[Gary Poster]
> FWIW, Jim just showed me that
>
> import datetime
> import sys
> sys.modules['datetime._datetime'] = sys.modules['datetime']
>
> works as a hack (which I'm sure is known by most folks, but hey, I
> didn't :-).
Ya, Jim does stuff like that in his sleep without even breaking a snore --
the rest of us have to take a few minutes to recover from cringing <wink>.
Note that the last line can be simplified a bit:
sys.modules['datetime._datetime'] = datetime
That works too.
After doing that dance under Python 2.3.2 in a current Zope3 checkout, I was
indeed able to load pickles (both protocol 0 and protocol 1) containing
datetime objects produced under Python 2.2.3 using Zope3's former Python
datetime implementation.
Note that Python 2.3 pickle supports an "extension code" registry, so that
protocol 2 pickles can contain tiny new opcodes referring to global names
indirectly (they effectively contain an index into a vector of
pre-registered global objects). We haven't exploited that ("we" meaning
neither Python nor Zope) yet, but it was specifically designed to reduce
pickle-size burden for popular classes with long-winded names. A pickle
using this has no chance of being read under pre-2.3 Python, though.
More information about the Zope3-dev
mailing list