Raymond Hettinger
a68cad13ae
Fix field name conflicts for named tuples.
2009-05-27 02:24:45 +00:00
Benjamin Peterson
7c67b03051
using sys._getframe(x), where x > 0 doesnt' work on IronPython
2009-05-05 00:55:24 +00:00
Raymond Hettinger
1355a3dbf6
Minor factoring.
2009-04-08 08:26:55 +00:00
Raymond Hettinger
a5cd6375c0
Add docstrings.
2009-04-08 05:39:38 +00:00
Raymond Hettinger
e3bc5577e8
Replace the localized min/max calls with normal if/else
2009-04-04 08:46:58 +00:00
Raymond Hettinger
756ab67a98
Have namedtuple's field renamer assign names that
...
are consistent with the corresponding tuple index.
2009-04-02 22:25:40 +00:00
Raymond Hettinger
2dc90fdfaf
Separate initialization from clearing.
2009-03-25 22:41:32 +00:00
Raymond Hettinger
e5b78563b6
Make imported name private and wrap long-line.
2009-03-23 18:26:59 +00:00
Raymond Hettinger
906f95e80b
Move initialization of root link to __init__.
2009-03-23 04:42:18 +00:00
Raymond Hettinger
f1e2df9780
Add more comments. Improve variable names.
...
Make links clearer by using a Link object
instead of a list. Use proxy links to avoid
circular references.
2009-03-23 00:08:09 +00:00
Raymond Hettinger
c8e81ef508
Fix typo
2009-03-19 23:22:25 +00:00
Raymond Hettinger
e980d2d44b
* Add implementation notes.
...
* Re-order methods so that those touching the underlying data
structure come first and the derived methods come last.
2009-03-19 23:12:41 +00:00
Raymond Hettinger
2412299be9
* Add clearer comment to initialization code.
...
* Add optional argument to popitem() -- modeled
after Anthon van der Neut's C version.
* Fix method markup in docs.
2009-03-19 19:59:58 +00:00
Raymond Hettinger
2124599eaa
Improve implementation with better underlying data structure
...
for O(1) deletions. Big-Oh performance now the same as regular
dictionaries. Uses a doubly-linked list instead of a list/seq
to track insertion order.
2009-03-19 15:21:10 +00:00
Raymond Hettinger
a61ae6922f
Use mixin methods where possible. (2.7 only -- these don't all exist in 3.0)
2009-03-18 22:13:20 +00:00
Raymond Hettinger
131af6505a
Backport 70140, 70141, 70143, and 70144.
...
Adds tests, switches from list to deque, fixes __reduce__
which was unnecessarily copying __keys.
2009-03-03 22:59:25 +00:00
Raymond Hettinger
0b15541ae2
Minor simplification.
2009-03-03 21:13:51 +00:00
Raymond Hettinger
9353ea2b85
Make the underlying data structure more private.
2009-03-03 20:53:51 +00:00
Raymond Hettinger
88a9164cdb
Backport 70106: Add OrderedDict support to collections.namedtuple().
2009-03-03 04:51:24 +00:00
Raymond Hettinger
bc512d3abd
Backport PEP 372: OrderedDict()
2009-03-03 04:45:34 +00:00
Raymond Hettinger
322daea7c3
Issue 1818: collections.namedtuple() to support automatic renaming of invalid fieldnames.
2009-02-10 01:24:05 +00:00
Raymond Hettinger
ecf252abac
Issue 5021: doctest.testfile should set __name__
2009-01-27 10:03:04 +00:00
Raymond Hettinger
1bc1c8ac76
Update comments and add an optimized path for Counter.update().
2009-01-22 09:05:43 +00:00
Raymond Hettinger
4571f347f9
Simplify explanation of multiset operations by removing restrictions on negative inputs.
2009-01-21 20:31:50 +00:00
Raymond Hettinger
ae3f068fb5
Make merging easier by formattng comment blocks the same in Py3.1
2009-01-20 03:36:36 +00:00
Raymond Hettinger
562a4ada56
Add Counter() to __all__.
2009-01-20 02:24:38 +00:00
Raymond Hettinger
bad1eb2ff3
Build-outs for Counter() class:
...
* Constructor and update() support keyword args (like their dict counterparts).
* The 'del' statement no longer raises KeyError for missing values.
* Add multiset operations: __add__, __sub__, __and__, __or__.
2009-01-20 01:19:26 +00:00
Raymond Hettinger
35288c6b6c
Speed-up __repr__. Eliminate duplicate tests. Use a from-irmport.
2009-01-13 04:50:35 +00:00
Raymond Hettinger
783d73fc2f
Fixup and simplify docstrings and doctests.
2009-01-13 04:13:53 +00:00
Raymond Hettinger
aaa6e630f8
Simplify Counter() API. Replace items keyword argument
...
with a mapping. Makes Counter() idempotent, makes update()
API the same as Counter.__init__(), makes a more readable
repr, makes the API more dict-like, and allows Steven
Bethard's update() example to work.
2009-01-13 01:05:03 +00:00
Raymond Hettinger
f94d7fa5fb
Issue 1696199: Add collections.Counter().
2009-01-12 22:58:41 +00:00
Raymond Hettinger
6ee7bc04f7
Fix namedtuple bug reported by Glenn Linderman. Template did not form correctly if the field names were input in Unicode.
2008-09-25 23:31:52 +00:00
Raymond Hettinger
e98839a1f4
Issue3065: Fixed pickling of named tuples. Added tests.
2008-06-09 01:28:30 +00:00
Raymond Hettinger
3c2523c2eb
Issue 2903: Add __name__ in globals for namedtuple namespace.
2008-05-30 07:16:53 +00:00
Raymond Hettinger
15b5e55b48
Neaten-up the named tuple docs
2008-01-10 23:00:01 +00:00
Raymond Hettinger
e850c466c7
Clarify how to add a field to a named tuple.
2008-01-10 20:37:12 +00:00
Raymond Hettinger
e1655088ca
Examples for named tuple subclassing should include __slots__
2008-01-10 19:15:10 +00:00
Raymond Hettinger
581671419f
Expand comment.
2008-01-08 02:02:05 +00:00
Raymond Hettinger
f5e8af1bb7
Use get() instead of pop() for the optimized version of _replace().
2008-01-07 20:56:05 +00:00
Raymond Hettinger
9a359210aa
Cleanup named tuple subclassing example.
2008-01-07 20:07:38 +00:00
Raymond Hettinger
dc55f35f38
Add another named tuple subclassing example.
2008-01-07 09:03:49 +00:00
Raymond Hettinger
1db6f80cd5
Cleanup subclassing example to more clearly show fixed-width print format.
2008-01-07 05:50:35 +00:00
Raymond Hettinger
b8e0072fec
Add subclassing example to docs for named tuples.
2008-01-07 04:24:49 +00:00
Raymond Hettinger
844f71b7e4
Speed-up named tuple's _make() constructor.
2008-01-06 22:11:54 +00:00
Raymond Hettinger
1166872006
Small code simplification. Forgot that classmethods can be called from intances.
2008-01-06 09:02:24 +00:00
Raymond Hettinger
1b50fd7cb3
Add error-checking to namedtuple's _replace() method.
2008-01-05 02:17:24 +00:00
Raymond Hettinger
02740f73ff
Improve namedtuple's _cast() method with a docstring, new name, and error-checking.
2008-01-05 01:35:43 +00:00
Raymond Hettinger
e0734e7dc0
Minor fix-ups to named tuples:
...
* Make the _replace() method respect subclassing.
* Using property() to make _fields read-only wasn't a good idea.
It caused len(Point._fields) to fail.
* Add note to _cast() about length checking and alternative with the star-operator.
2008-01-04 03:22:53 +00:00
Raymond Hettinger
85dfcf3530
Users demand iterable input for named tuples. The author capitulates.
2007-12-18 23:51:15 +00:00
Raymond Hettinger
8777bcae27
Simplify and speedup _asdict() for named tuples.
2007-12-18 22:21:27 +00:00