summaryrefslogtreecommitdiffstats
path: root/Objects/dictobject.c
Commit message (Collapse)AuthorAgeFilesLines
...
* Variation of patch # 1624059 to speed up checking if an object is a subclassNeal Norwitz2007-02-251-1/+1
| | | | | | | | | | | | | | | | | | of some of the common builtin types. Use a bit in tp_flags for each common builtin type. Check the bit to determine if any instance is a subclass of these common types. The check avoids a function call and O(n) search of the base classes. The check is done in the various Py*_Check macros rather than calling PyType_IsSubtype(). All the bits are set in tp_flags when the type is declared in the Objects/*object.c files because PyType_Ready() is not called for all the types. Should PyType_Ready() be called for all types? If so and the change is made, the changes to the Objects/*object.c files can be reverted (remove setting the tp_flags). Objects/typeobject.c would also have to be modified to add conditions for Py*_CheckExact() in addition to each the PyType_IsSubtype check.
* Extend work on revision 52962: Eliminate redundant calls to PyObject_Hash().Raymond Hettinger2007-02-191-0/+39
|
* SF #1615701: make d.update(m) honor __getitem__() and keys() in dict subclassesRaymond Hettinger2007-02-071-1/+1
|
* Fix refleakNeal Norwitz2006-10-291-0/+1
|
* Bug #1576657: when setting a KeyError for a tuple key, make sure thatGeorg Brandl2006-10-291-3/+16
| | | | the tuple isn't used as the "exception arguments tuple".
* Fix warnings with HP's C compiler. It doesn't recognize that infiniteNeal Norwitz2006-10-281-0/+4
| | | | | | loops are, um, infinite. These conditions should not be able to happen. Will backport.
* Fix SF bug #1546288, crash in dict_equal.Neal Norwitz2006-09-051-0/+3
|
* Typo fixesAndrew M. Kuchling2006-08-041-1/+1
|
* Add some asserts that we got good params passedNeal Norwitz2006-07-211-0/+3
|
* SF bug #1503294.Armin Rigo2006-06-101-1/+1
| | | | PyThreadState_GET() complains if the tstate is NULL, but only in debug mode.
* Armin committed his patch while I was reviewing it (I'm sureTim Peters2006-06-011-28/+40
| | | | | | | | he didn't know this), so merged in some changes I made during review. Nothing material apart from changing a new `mask` local from int to Py_ssize_t. Mostly this is repairing comments that were made incorrect, and adding new comments. Also a few minor code rewrites for clarity or helpful succinctness.
* [ 1497053 ] Let dicts propagate the exceptions in user __eq__().Armin Rigo2006-06-011-50/+107
| | | | [ 1456209 ] dictresize() vulnerability ( <- backport candidate ).
* dict_print(): So that Neal & I don't spend the rest ofTim Peters2006-05-301-4/+5
| | | | | | our lives taking turns rewriting code that works ;-), get rid of casting illusions by declaring a new variable with the obvious type.
* dict_print(): Explicitly narrow the return valueTim Peters2006-05-301-1/+1
| | | | from a (possibly) wider variable.
* No DOWNCAST is required since sizeof(Py_ssize_t) >= sizeof(int) and ↵Neal Norwitz2006-05-301-1/+1
| | | | Py_ReprEntr returns an int
* Use Py_SAFE_DOWNCAST for safety. Fix format strings. Remove 2 more stray | ↵Neal Norwitz2006-05-301-6/+6
| | | | in comment
* Remove stray | in commentNeal Norwitz2006-05-301-1/+1
|
* Convert relevant dict internals to Py_ssize_t.Tim Peters2006-05-301-43/+55
| | | | | | I don't have a box with nearly enough RAM, or an OS, that could get close to tickling this, though (requires a dict w/ at least 2**31 entries).
* Use Py_VISIT in all tp_traverse methods, instead of traversing manually orThomas Wouters2006-04-151-7/+2
| | | | | | | | using a custom, nearly-identical macro. This probably changes how some of these functions are compiled, which may result in fractionally slower (or faster) execution. Considering the nature of traversal, visiting much of the address space in unpredictable patterns, I'd argue the code readability and maintainability is well worth it ;P
* Ignore the references to the dummy objects used as deleted keysArmin Rigo2006-04-121-0/+8
| | | | in dicts and sets when computing the total number of references.
* Remove unnecessary casts in type object initializers.Georg Brandl2006-03-301-13/+13
|
* Oops. Fix syntax for C89 compilers.Guido van Rossum2006-02-251-2/+2
|
* - Patch 1433928:Guido van Rossum2006-02-251-1/+15
| | | | | | | | - The copy module now "copies" function objects (as atomic objects). - dict.__getitem__ now looks for a __missing__ hook before raising KeyError. - Added a new type, defaultdict, to the collections module. This uses the new __missing__ hook behavior added to dict (see above).
* Revert 42400.Martin v. Löwis2006-02-161-1/+1
|
* Support %zd in PyErr_Format and PyString_FromFormat.Martin v. Löwis2006-02-161-1/+1
|
* Get rid of compiler warnings (gcc 3.3.4 on x86)Neal Norwitz2006-02-161-1/+1
|
* Merge ssize_t branch.Martin v. Löwis2006-02-151-15/+17
|
* Renamed _length_cue() to __length_hint__(). See:Armin Rigo2006-02-111-2/+2
| | | | http://mail.python.org/pipermail/python-dev/2006-February/060524.html
* Fixed English in a comment; trimmed trailing whitespace;Tim Peters2006-01-011-11/+11
| | | | no code changes.
* Convert iterator __len__() methods to a private API.Raymond Hettinger2005-09-241-9/+18
|
* Fix nits.Raymond Hettinger2005-08-171-2/+2
|
* SF patch #1200051: Small optimization for PyDict_Merge()Raymond Hettinger2005-05-141-0/+6
| | | | (Contributed by Barry Warsaw and Matt Messier.)
* SF bug #1183742: PyDict_Copy() can return non-NULL value on errorRaymond Hettinger2005-04-151-1/+1
|
* Code simplification -- eliminate lookup when value is known in advance.Raymond Hettinger2005-02-051-2/+4
|
* Moved SunPro warning suppression into pyport.h and out of individualNicholas Bastin2004-07-151-4/+0
| | | | modules and objects.
* Disabling end-of-loop code not reached warning on SunProNicholas Bastin2004-06-181-0/+4
|
* Update docstring for dict.update() to match the new realities.Walter Dörwald2004-05-281-1/+2
|
* * Add unittests for iterators that report their lengthRaymond Hettinger2004-04-121-7/+7
| | | | | | * Document the differences between them * Fix corner cases covered by the unittests * Use Py_RETURN_NONE where possible for dictionaries
* GCC was complaining that 'value' in dictiter_iternextvalue() wasn'tGuido van Rossum2004-03-201-5/+6
| | | | | | necessarily always set before used. Between Tim, Armin & me we couldn't prove GCC wrong, so we decided to fix the algorithm. This version is Armin's.
* Factor out a double lookup.Raymond Hettinger2004-03-191-2/+1
|
* Make the new dictionary iterators transparent with respect to length.Raymond Hettinger2004-03-181-4/+20
| | | | | | This gives another 30% speedup for operations such as map(func, d.iteritems()) or list(d.iteritems()) which can both take advantage of length information when provided.
* Optimize dictionary iterators.Raymond Hettinger2004-03-181-57/+202
| | | | | | | | | | | | | | | | | | * Split into three separate types that share everything except the code for iternext. Saves run time decision making and allows each iternext function to be specialized. * Inlined PyDict_Next(). In addition to saving a function call, this allows a redundant test to be eliminated and further specialization of the code for the unique needs of each iterator type. * Created a reusable result tuple for iteritems(). Saves the malloc time for tuples when the previous result was not kept by client code (this is the typical use case for iteritems). If the client code does keep the reference, then a new tuple is created. Results in a 20% to 30% speedup depending on the size and sparsity of the dictionary.
* Dictionary optimizations:Raymond Hettinger2004-03-171-24/+61
| | | | | | | | | | | | * Factored constant structure references out of the inner loops for PyDict_Next(), dict_keys(), dict_values(), and dict_items(). Gave measurable speedups to each (the improvement varies depending on the sparseness of the dictionary being measured). * Added a freelist scheme styled after that for tuples. Saves around 80% of the calls to malloc and free. About 10% of the time, the previous dictionary was completely empty; in those cases, the dictionary initialization with memset() can be skipped.
* Factor out code common to PyDict_Copy() and PyDict_Merge().Raymond Hettinger2004-03-081-20/+6
|
* SF #904720: dict.update should take a 2-tuple sequence like dict.__init_Raymond Hettinger2004-03-041-18/+24
| | | | | | | | (Championed by Bob Ippolito.) The update() method for mappings now accepts all the same argument forms as the dict() constructor. This includes item lists and/or keyword arguments.
* Oops. Return -1 to distinguish error from empty dict.Jeremy Hylton2004-02-171-1/+1
| | | | | This change probably isn't work a bug fix. It's unlikely that anyone was calling this method without passing it a real dict.
* Simplify previous checkin -- a new function was not needed.Raymond Hettinger2003-12-131-26/+1
|
* * Added a new method flag, METH_COEXIST.Raymond Hettinger2003-12-131-0/+34
| | | | | * Used the flag to optimize set.__contains__(), dict.__contains__(), dict.__getitem__(), and list.__getitem__().
* Expose dict_contains() and PyDict_Contains() with is about 10% fasterRaymond Hettinger2003-11-251-3/+4
| | | | | | | than PySequence_Contains() and more clearly applicable to dicts. Apply the new function in setobject.c where __contains__ checking is ubiquitous.
* SF patch #798467: Update docstring of has_key for bool changesRaymond Hettinger2003-09-011-1/+1
| | | | (Contributed by George Yoshida.)