[ZODB-Dev] Backward-incompatible change in TimeStamp repr in ZODB 4.

Jim Fulton jim at zope.com
Sun Sep 29 18:06:34 CEST 2013


TimeStamps are used mainly to convert between high-level
date-time representations and 8-byte binary transaction IDs.
Historically, a TimeStamp's repr was used to retrieve the binary
representation.  repr was used because, under the hood, slots
are much faster to access than methods.

In ZODB 3.3, a TimeStamp raw method was added to retrieve
the binary data for a time stamp.  I wasn't actually aware of this
until recently.  From an API point of view, using raw rather than
repr is cleaner.  I don't know if the performance implications
are significant, though probably not.

In Python 3, __repr__ returns Unicode, rather than binary data,
so it's no-longer possible to use it to get the binary representation
of a time stamp.  TimeStamp's __repr__ was changed to
return the repr of it's binary data.  Python 3 was going to have
to be broken, but this was also a breaking change for Python 2.

I don't remember this issue being raised earlier. If so, I missed it.

In any case, going forward, it's best to embrace raw() as the correct
way to get the binary representation of time stamps.  This is
mainly a heads up for people porting to ZODB 4.

I don't really see much value in returning the repr of the binary
data.  I'd at least wrap the string in a TimeStamp call, something
like "TimeStamp(b'...').

I'd hoped that ZODB 4.0 would be backward compatible with
ZODB3.  That's why ZODB3 3.11 is a meta package that
requires the ZODB 4 packages.  Unfortunately, this means
that ZODB3 3.11 isn't backward compatible.  Fortunately,
ZODB 3.11.0 is still in alpha. :)

I think the best option is to release what is currently
ZODB3 3.11.0a3 as ZODB3 4.0.0.  This will allow
packages that depend on ZODB3 to be used with
ZODB 4, but it will clearly label the ZODB4 4.0.0 release
as not backward compatible.

Another option is to leave things as they are.
Since buildout 2, and now pip, prefer final releases,
existing applications that use current buildout or pip
aren't broken by ZODB3 3.11a3, even if they don't
pin versions.  If someone wants to mix ZODB3 and
ZODB 4, they can explicitly require ZODB3 3.11a3.

Thoughts?

Jim

-- 
Jim Fulton
http://www.linkedin.com/in/jimfulton


More information about the ZODB-Dev mailing list