12 years of Python and only at v2.2

Tim Peters tim.one at comcast.net
Thu Dec 5 19:42:49 EST 2002


[Greg Ewing]
> Hmmm. I wonder if there's some generalisation of the
> notion of monotonicity when you're dealing with a
> tree rather than a linear sequence?

[Erik Max Francis]
> Yeah, I deliberately kind of glossed over that, and presumed we'd use
> some reasonable mapping of version numbers to real numbers in such a
> way that they'd have a well-ordering in the "way you'd expect" (how's
> that for mathematical rigor), even in spite of multiple dots (even
> perhaps more than 2 as in x.y.z.w).  (It's not hard to construct one,
> of course, which is why I glossed over it.)

>>> import sys
>>> sys.version_info
(2, 3, 0, 'alpha', 1)
>>>

That is, you don't need reals, you just need lexicographic ordering on
tuples.  Code like

if sys.version_info >= (2, 3):
    # at or after version 2.3

works as intended.  At least for finite, ordered, edge-labelled trees, if
the arcs from each node have monotonically increasing labels "left to
right", associate each node with the tuple of labels on the path from the
root, and then the lexicographic ordering of the tuples is the same as you'd
get from a preorder tree traversal.





More information about the Python-list mailing list