~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/_static_tuple_py.py

  • Committer: John Arbash Meinel
  • Date: 2010-02-17 17:11:16 UTC
  • mfrom: (4797.2.17 2.1)
  • mto: (4797.2.18 2.1)
  • mto: This revision was merged to the branch mainline in revision 5055.
  • Revision ID: john@arbash-meinel.com-20100217171116-h7t9223ystbnx5h8
merge bzr.2.1 in preparation for NEWS entry.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2009 Canonical Ltd
 
1
# Copyright (C) 2009, 2010 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
24
24
class StaticTuple(tuple):
25
25
    """A static type, similar to a tuple of strings."""
26
26
 
 
27
    __slots__ = ()
 
28
 
27
29
    def __new__(cls, *args):
28
30
        # Make the empty StaticTuple a singleton
29
31
        if not args and _empty_tuple is not None:
48
50
    def __repr__(self):
49
51
        return '%s%s' % (self.__class__.__name__, tuple.__repr__(self))
50
52
 
 
53
    def __reduce__(self):
 
54
        return (StaticTuple, tuple(self))
 
55
 
51
56
    def __add__(self, other):
52
57
        """Concatenate self with other"""
53
58
        return StaticTuple.from_sequence(tuple.__add__(self,other))
54
59
 
55
60
    def as_tuple(self):
56
 
        return self
 
61
        return tuple(self)
57
62
 
58
63
    def intern(self):
59
64
        return _interned_tuples.setdefault(self, self)