[PATCH 2 of 6] Provide a version independent way to use the set datatype
Eric M. Hopper
hopper at omnifarious.org
Sun Jun 10 16:26:19 CDT 2007
On Sun, 2007-06-10 at 15:58 -0500, Matt Mackall wrote:
> On Thu, Jun 07, 2007 at 03:58:08PM -0700, Eric Hopper wrote:
> > # HG changeset patch
> > # User Eric Hopper <hopper at omnifarious.org>
> > # Date 1181256552 25200
> > # Node ID d8f52bfc3b38809aff35efb8a34a6347ba228af7
> > # Parent 04f49562a1eb805adfa78349c64561a539538e6f
> > Provide a version independent way to use the set datatype.
> >
> > diff --git a/mercurial/util.py b/mercurial/util.py
> > --- a/mercurial/util.py
> > +++ b/mercurial/util.py
> > @@ -15,6 +15,13 @@ from i18n import _
> > from i18n import _
> > import cStringIO, errno, getpass, popen2, re, shutil, sys, tempfile
> > import os, threading, time, calendar, ConfigParser, locale, glob
> > +
> > +try:
> > + hgset = set
> > + hgfrozenset = frozenset
> > +except NameError, e:
> > + from sets import Set as hgset
> > + from sets import ImmutableSet as hgfrozenset
>
> Why do we want this?
>
> On my box:
> Python 2.4 Python 2.5
> set dict set dict
> add 10000 elements to a set: 3.8ms 2.7ms 3.5ms 2.8ms
> find 10000 members in a set: 3.5ms 3.4ms 3.3ms 3.4ms
> total: 7.3ms 6.1ms 6.8ms 6.2ms
Oh, wow, I should've done that test. :-( That's pretty irritating.
I like sets better because I think they provide for a clearer expression
of an algorithm in many cases.
Hmmm,
--
The best we can hope for concerning the people at large is that they
be properly armed. -- Alexander Hamilton
-- Eric Hopper (hopper at omnifarious.org http://www.omnifarious.org/~hopper) --
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 185 bytes
Desc: This is a digitally signed message part
Url : http://selenic.com/pipermail/mercurial-devel/attachments/20070610/4f05bf23/attachment.pgp
More information about the Mercurial-devel
mailing list