Christian Heimes
e93237dfcc
#1629 : Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and Py_REFCNT. Macros for b/w compatibility are available.
2007-12-19 02:37:44 +00:00
Raymond Hettinger
fd7ed407d7
Give meaning to the oparg for BUILD_MAP: estimated size of the dictionary.
...
Allows dictionaries to be pre-sized (upto 255 elements) saving time lost
to re-sizes with their attendant mallocs and re-insertions.
Has zero effect on small dictionaries (5 elements or fewer), a slight
benefit for dicts upto 22 elements (because they had to resize once
anyway), and more benefit for dicts upto 255 elements (saving multiple
resizes during the build-up and reducing the number of collisions on
the first insertions). Beyond 255 elements, there is no addional benefit.
2007-12-18 21:24:09 +00:00
Georg Brandl
ede3a3218e
Spaces vs. Tabs.
2007-11-29 18:33:01 +00:00
Guido van Rossum
31645ba4a0
Fix bug #1517 , a segfault in lookdict().
2007-11-29 18:25:12 +00:00
Guido van Rossum
64c06e327d
Backport of _abccoll.py by Benjamin Arangueren, issue 1383.
...
With some changes of my own thrown in (e.g. backport of r58107).
2007-11-22 00:55:51 +00:00
Raymond Hettinger
34448790db
Optimize common case for dict.fromkeys().
2007-11-09 23:14:44 +00:00
Raymond Hettinger
cdcf887999
Optimize dict.fromkeys() with dict inputs. Useful for resetting bag/muliset counts for example.
2007-11-07 02:26:17 +00:00
Brett Cannon
77ae87c11e
Remove file-level typedefs that were inconsistently used throughout the file.
...
Just move over to the public API names.
Closes issue1238.
2007-10-10 00:07:50 +00:00
Brett Cannon
0153159e67
Add a bunch of GIL release/acquire points in tp_print implementations and for
...
PyObject_Print().
Closes issue #1164 .
2007-09-17 03:28:34 +00:00
Martin v. Löwis
6819210b9e
PEP 3123: Provide forward compatibility with Python 3.0, while keeping
...
backwards compatibility. Add Py_Refcnt, Py_Type, Py_Size, and
PyVarObject_HEAD_INIT.
2007-07-21 06:55:02 +00:00
Neal Norwitz
c792629c83
Whitespace cleanup
2007-05-23 06:57:35 +00:00
Neal Norwitz
8b2bfbc198
Add -3 option to the interpreter to warn about features that are
...
deprecated and will be changed/removed in Python 3.0.
This patch is mostly from Anthony. I tweaked some format and added
a little doc.
2007-05-23 06:35:32 +00:00
Raymond Hettinger
e3146f5aa3
Add test and fix for fromkeys() optional argument.
2007-03-21 20:33:57 +00:00
Raymond Hettinger
0bbbfc4c0b
Extend work on rev 52962 and 53829 eliminating redundant PyObject_Hash() calls and fixing set/dict interoperability.
2007-03-20 21:27:24 +00:00
Neal Norwitz
ee3a1b5244
Variation of patch # 1624059 to speed up checking if an object is a subclass
...
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.
2007-02-25 19:44:48 +00:00
Raymond Hettinger
d6fc72a5ae
Extend work on revision 52962: Eliminate redundant calls to PyObject_Hash().
2007-02-19 02:03:19 +00:00
Raymond Hettinger
0922d71604
SF #1615701 : make d.update(m) honor __getitem__() and keys() in dict subclasses
2007-02-07 20:08:22 +00:00
Neal Norwitz
7b932da443
Fix refleak
2006-10-29 23:39:03 +00:00
Georg Brandl
b9f4ad3a9a
Bug #1576657 : when setting a KeyError for a tuple key, make sure that
...
the tuple isn't used as the "exception arguments tuple".
2006-10-29 18:31:42 +00:00
Neal Norwitz
a5ccda95f2
Fix warnings with HP's C compiler. It doesn't recognize that infinite
...
loops are, um, infinite. These conditions should not be able to happen.
Will backport.
2006-10-28 21:16:54 +00:00
Neal Norwitz
a22975fb35
Fix SF bug #1546288 , crash in dict_equal.
2006-09-05 02:24:03 +00:00
Andrew M. Kuchling
0067b5fa2b
Typo fixes
2006-08-04 20:37:43 +00:00
Neal Norwitz
48808a1d6c
Add some asserts that we got good params passed
2006-07-21 05:29:58 +00:00
Armin Rigo
acd0d6d416
SF bug #1503294 .
...
PyThreadState_GET() complains if the tstate is NULL, but only in debug mode.
2006-06-10 10:57:40 +00:00
Tim Peters
d770ebd286
Armin committed his patch while I was reviewing it (I'm sure
...
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.
2006-06-01 15:50:44 +00:00
Armin Rigo
35f6d36951
[ 1497053 ] Let dicts propagate the exceptions in user __eq__().
...
[ 1456209 ] dictresize() vulnerability ( <- backport candidate ).
2006-06-01 13:19:12 +00:00
Tim Peters
33f4a6a31a
dict_print(): So that Neal & I don't spend the rest of
...
our lives taking turns rewriting code that works ;-),
get rid of casting illusions by declaring a new variable
with the obvious type.
2006-05-30 05:23:59 +00:00
Tim Peters
638144305c
dict_print(): Explicitly narrow the return value
...
from a (possibly) wider variable.
2006-05-30 05:04:59 +00:00
Neal Norwitz
5e1b45dc21
No DOWNCAST is required since sizeof(Py_ssize_t) >= sizeof(int) and Py_ReprEntr returns an int
2006-05-30 04:43:23 +00:00
Neal Norwitz
d3881b026c
Use Py_SAFE_DOWNCAST for safety. Fix format strings. Remove 2 more stray | in comment
2006-05-30 04:25:05 +00:00
Neal Norwitz
80af59cbd4
Remove stray | in comment
2006-05-30 04:19:21 +00:00
Tim Peters
9b10f7e0cb
Convert relevant dict internals to Py_ssize_t.
...
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).
2006-05-30 04:16:25 +00:00
Thomas Wouters
c6e55068ca
Use Py_VISIT in all tp_traverse methods, instead of traversing manually or
...
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
2006-04-15 21:47:09 +00:00
Armin Rigo
e170937af6
Ignore the references to the dummy objects used as deleted keys
...
in dicts and sets when computing the total number of references.
2006-04-12 17:06:05 +00:00
Georg Brandl
347b30042b
Remove unnecessary casts in type object initializers.
2006-03-30 11:57:00 +00:00
Guido van Rossum
4b92a82504
Oops. Fix syntax for C89 compilers.
2006-02-25 23:32:30 +00:00
Guido van Rossum
1968ad32cd
- Patch 1433928:
...
- 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).
2006-02-25 22:38:04 +00:00
Martin v. Löwis
e0e89f7920
Revert 42400.
2006-02-16 06:59:22 +00:00
Martin v. Löwis
2c95cc6d72
Support %zd in PyErr_Format and PyString_FromFormat.
2006-02-16 06:54:25 +00:00
Neal Norwitz
26efe402c2
Get rid of compiler warnings (gcc 3.3.4 on x86)
2006-02-16 06:21:57 +00:00
Martin v. Löwis
18e165558b
Merge ssize_t branch.
2006-02-15 17:27:45 +00:00
Armin Rigo
f5b3e36493
Renamed _length_cue() to __length_hint__(). See:
...
http://mail.python.org/pipermail/python-dev/2006-February/060524.html
2006-02-11 21:32:43 +00:00
Tim Peters
60b29961dc
Fixed English in a comment; trimmed trailing whitespace;
...
no code changes.
2006-01-01 01:19:23 +00:00
Raymond Hettinger
6b27cda643
Convert iterator __len__() methods to a private API.
2005-09-24 21:23:05 +00:00
Raymond Hettinger
f81e45023e
Fix nits.
2005-08-17 02:19:36 +00:00
Raymond Hettinger
186e739d29
SF patch #1200051 : Small optimization for PyDict_Merge()
...
(Contributed by Barry Warsaw and Matt Messier.)
2005-05-14 18:08:25 +00:00
Raymond Hettinger
1356f785c1
SF bug #1183742 : PyDict_Copy() can return non-NULL value on error
2005-04-15 15:58:42 +00:00
Raymond Hettinger
07ead17318
Code simplification -- eliminate lookup when value is known in advance.
2005-02-05 23:42:57 +00:00
Nicholas Bastin
9ba301e589
Moved SunPro warning suppression into pyport.h and out of individual
...
modules and objects.
2004-07-15 15:54:05 +00:00
Nicholas Bastin
9e1bfe7dd9
Disabling end-of-loop code not reached warning on SunPro
2004-06-18 19:57:13 +00:00