StaticTuple... naming, maintenance, ...

John Arbash Meinel john at arbash-meinel.com
Tue Oct 6 19:33:35 BST 2009


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


4) Another fundamental question.

Should these compare identical to their equivalent tuples.

Right now:

  StaticTuple(a, b) == (a, b)

In all ways (including hash()).

I wrote it this way to make them a trivial 'drop-in' replacement
wherever we want to put them.

The good of that is that it makes it easier to migrate. The bad of that
is that it makes it easier to change something and no longer maintain
the decreased memory consumption.

If we forced keys to be StaticTuples, it would effect quite a bit of
code, but then that code would be guaranteed to stay in that state.
Since apis would say:

  if type(x) is StaticTuple:

rather than

  if type(x) in (tuple, StaticTuple)
...

I'm not 100% positive, but we may also be able to get away with:

class StaticTuple(tuple):
  def __init__(self, *args):
    # Check that self.args is valid.
    tuple.__init__(self, args)

And then preserve a pure-python class that doesn't wrap tuple, but just
extends it slightly. That should also get around the memory consumption
issue I brought up earlier.

John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkrLjX8ACgkQJdeBCYSNAAM1bACgrrAX4PlLQaiVDkIMkI+wZSPf
BuEAoK5OzhZKAjKHLYcQVxlN3/LOtDio
=In7l
-----END PGP SIGNATURE-----



More information about the bazaar mailing list