Commit Graph

1914 Commits

Author SHA1 Message Date
Raymond Hettinger 8657845e02 SF bug #692959: new.function ignores keyword arguments 2003-05-06 09:01:41 +00:00
Raymond Hettinger 3539f6b895 SF patch #729395: Dictionary tuning
* Increase dictionary growth rate resulting in more sparse dictionaries,
  fewer lookup collisions, increased memory use, and better cache
  performance.  For dicts with over 50k entries, keep the current
  growth rate in case an application is suffering from tight memory
  constraints.

* Set the most common case (no resize) to fall-through the test.
2003-05-05 22:22:10 +00:00
Raymond Hettinger 4887a12133 Add notes from python-dev about readonly dictionaries. 2003-05-05 21:31:51 +00:00
Tim Peters c7bc0b98e7 SF patch 730594: assert from longobject.c, line 1215.
Some version of gcc in the "RTEMS port running on the Coldfire (m5200)
processor" generates bad code for a loop in long_from_binary_base(),
comparing the wrong half of an int to a short.  The patch changes the
decl of the short temp to be an int temp instead.  This "simplifies"
the code enough that gcc no longer blows it.
2003-05-05 20:39:43 +00:00
Raymond Hettinger 258dfebfb4 * Note how dummy entry re-use benefits use cases with interspersed deletes
and adds.

* Note that dictionary iteration is negatively impacted by additional
  sparseness.
2003-05-04 21:25:19 +00:00
Tim Peters 015dd82136 Somewhere along the way, the softspace attr of file objects became read-
only.  Repaired, and added new tests to test_file.py.
2003-05-04 04:16:52 +00:00
Martin v. Löwis cd12bfc142 Patch #708604: Check more function results. Will backport to 2.2. 2003-05-03 10:53:08 +00:00
Raymond Hettinger 930427b892 Add a reference to dictnotes.txt. It does no good if you don't know it's
there or where to find it.
2003-05-03 06:51:59 +00:00
Raymond Hettinger 5466296f02 Research notes and explorations for optimizing Python dictionaries. 2003-05-02 20:11:29 +00:00
Jeremy Hylton fc61f9a36e Silence compiler warnings in VC 7. 2003-05-01 21:31:53 +00:00
Tim Peters 2af713c2f7 Squashed new compiler wngs about trying to compare pointers to
functions with different signatures.
2003-04-24 20:59:52 +00:00
Raymond Hettinger 9928571f3f SF bug 665835: filter() treatment of str and tuple inconsistent
As a side issue on this bug, it was noted that list and tuple iterators
used macros to directly access containers and would not recognize
__getitem__ overrides.  If the method is overridden, the patch returns
a generic sequence iterator which calls the __getitem__ method; otherwise,
it returns a high custom iterator with direct access to container elements.
2003-04-24 16:52:47 +00:00
Guido van Rossum 636688d470 Improve the message about metatype/metaclass conflicts. 2003-04-23 12:07:22 +00:00
Jeremy Hylton fbbe34789e Add a useful docstring to enumerate. 2003-04-21 20:26:25 +00:00
Guido van Rossum aa86e35c52 - bool() called without arguments now returns False rather than
raising an exception.  This is consistent with calling the
  constructors for the other builtin types -- called without argument
  they all return the false value of that type.  (SF patch #724135)
  Thanks to Alex Martelli.
2003-04-19 18:15:10 +00:00
Tim Peters 21d7d4d5ca _Py_PrintReferenceAddresses(): also print the type name. In real use
I'm finding some pretty baffling output, like reprs consisting entirely
of three left parens.  At least this will let us know what type the object
is (it's not str -- there's no quote character in the repr).

New tool combinerefs.py, to combine the two output blocks produced via
PYTHONDUMPREFS.
2003-04-18 00:45:59 +00:00
Tim Peters 269b2a6797 _Py_PrintReferences(): Changed to print object address at start of each
new line.

New pvt API function _Py_PrintReferenceAddresses():  Prints only the
addresses and refcnts of the live objects.  This is always safe to call,
because it has no dependence on Python's C API.

Py_Finalize():  If envar PYTHONDUMPREFS is set, call (the new)
_Py_PrintReferenceAddresses() right before dumping final pymalloc stats.
We can't print the reprs of the objects here because too much of the
interpreter has been shut down.  You need to correlate the addresses
displayed here with the object reprs printed by the earlier
PYTHONDUMPREFS call to _Py_PrintReferences().
2003-04-17 19:52:29 +00:00
Thomas Heller a4ea603b05 SF # 595026: support for masks in getargs.c.
New functions:
  unsigned long PyInt_AsUnsignedLongMask(PyObject *);
  unsigned PY_LONG_LONG) PyInt_AsUnsignedLongLongMask(PyObject *);
  unsigned long PyLong_AsUnsignedLongMask(PyObject *);
  unsigned PY_LONG_LONG) PyLong_AsUnsignedLongLongMask(PyObject *);

New and changed format codes:

b unsigned char 0..UCHAR_MAX
B unsigned char none **
h unsigned short 0..USHRT_MAX
H unsigned short none **
i int INT_MIN..INT_MAX
I * unsigned int 0..UINT_MAX
l long LONG_MIN..LONG_MAX
k * unsigned long none
L long long LLONG_MIN..LLONG_MAX
K * unsigned long long none

Notes:

* New format codes.

** Changed from previous "range-and-a-half" to "none"; the
range-and-a-half checking wasn't particularly useful.

New test test_getargs2.py, to verify all this.
2003-04-17 18:55:45 +00:00
Guido van Rossum c1f6e8cbc1 - The repr() of a weakref object now shows the __name__ attribute of
the referenced object, if it has one.

Also use %p to format pointers consistently, and use <weakproxy ...>
in proxy_repr(), to match the type name.
2003-04-16 21:13:23 +00:00
Guido van Rossum 6cc5bb685d Sigh. The crucial change was still missing from the previous
checkin. :-(
2003-04-16 20:01:36 +00:00
Guido van Rossum 76ba09fd81 - super() no longer ignores data descriptors, except __class__. See
the thread started at
  http://mail.python.org/pipermail/python-dev/2003-April/034338.html
2003-04-16 19:40:58 +00:00
Guido van Rossum 19a02ba69d Fix three (!) object leaks in the code for assignment to __bases__. 2003-04-15 22:09:45 +00:00
Guido van Rossum 52b2705e9c Ouch, it's Carlo Verre, not Verre Carlo. 2003-04-15 20:05:10 +00:00
Guido van Rossum 0fc8f00252 - pythunrun.c, Py_Finalize(): move the call to _Py_PrintReferences()
even farther down, to just before the call to
  _PyObject_DebugMallocStats().  This required the following changes:

- pystate.c, PyThreadState_GetDict(): changed not to raise an
  exception or issue a fatal error when no current thread state is
  available, but simply return NULL without raising an exception
  (ever).

- object.c, Py_ReprEnter(): when PyThreadState_GetDict() returns NULL,
  don't raise an exception but return 0.  This means that when
  printing a container that's recursive, printing will go on and on
  and on.  But that shouldn't happen in the case we care about (see
  first bullet).

- Updated Misc/NEWS and Doc/api/init.tex to reflect changes to
  PyThreadState_GetDict() definition.
2003-04-15 15:12:39 +00:00
Guido van Rossum 4dcdb78c6f Close off the "Verre Carlo hack" as discussed on python-dev. 2003-04-14 21:46:03 +00:00
Guido van Rossum 2fd02eb80f super_getattro(): kill some dead code; explain a mystery. 2003-04-14 21:20:26 +00:00
Guido van Rossum 3a3cca5b82 - list.insert(i, x) now interprets negative i as it would be
interpreted by slicing, so negative values count from the end of the
  list.  This was the only place where such an interpretation was not
  placed on a list index.
2003-04-14 20:58:14 +00:00
Neal Norwitz ffe33b7f24 Attempt to make all the various string *strip methods the same.
* Doc - add doc for when functions were added
 * UserString
 * string object methods
 * string module functions
'chars' is used for the last parameter everywhere.

These changes will be backported, since part of the changes
have already been made, but they were inconsistent.
2003-04-10 22:35:32 +00:00
Jeremy Hylton d06483c2f6 Missing DECREF. 2003-04-09 21:01:42 +00:00
Guido van Rossum 2fb9fdc96a Make it possible to call instancemethod() with 2 arguments. 2003-04-09 19:35:08 +00:00
Guido van Rossum a7132189d2 Reformat a few docstrings that caused line wraps in help() output. 2003-04-09 19:32:45 +00:00
Guido van Rossum 00bf8280f5 property_traverse() should also traverse into prop_doc -- there's no
typecheck that guarantees it's a string, and BTW string subclasses
could hide references.
2003-04-09 17:05:33 +00:00
Jeremy Hylton 400d8ee6fa Make staticmethods and classmethods participate in GC.
If a class was defined inside a function, used a static or class
method, and used super() inside the method body, it would be caught in
an uncollectable cycle.  (Simplified version: The static/class method
object would point to a function object with a closure that referred
to the class.)

Bugfix candidate.
2003-04-08 21:28:47 +00:00
Tim Peters df875b99fc New private API function _PyInstance_Lookup. gc will use this to figure
out whether __del__ exists, without executing any Python-level code.
2003-04-07 17:51:59 +00:00
Raymond Hettinger f394df47fd SF bug #699934: Obscure error message
mwh pointed out that the error message did not
make sense if obtained by rearranging the bases.
2003-04-06 19:13:41 +00:00
Walter Dörwald 44f527fea4 Change formatchar(), so that u"%c" % 0xffffffff now raises
an OverflowError instead of a TypeError to be consistent
with "%c" % 256. See SF patch #710127.
2003-04-02 16:37:24 +00:00
Walter Dörwald 43440a621e Fix PyString_Format() so that '%c' % u'a' returns u'a'
instead of raising a TypeError. (From SF patch #710127)

Add tests to verify this is fixed.

Add various tests for '%c' % int.
2003-03-31 18:07:50 +00:00
Martin v. Löwis b9a0f91218 Rename LONG_LONG to PY_LONG_LONG. Fixes #710285. 2003-03-29 10:06:18 +00:00
Guido van Rossum 8d24ee97df Refactoring: rename update_these_slots() into update_subclasses() and
generalize to take a callback function and a void * data argument.
This might come in handy later... :-)
2003-03-24 23:49:49 +00:00
Tim Peters 51f8d38185 Typo in comment. 2003-03-23 18:06:08 +00:00
Tim Peters 7571a0fbcf Improved new Py_TRACE_REFS gimmicks.
Arranged that all the objects exposed by __builtin__ appear in the list
of all objects.  I basically peed away two days tracking down a mystery
leak in sys.gettotalrefcount() in a ZODB app (== tons of code), because
the object leaking the references didn't appear in the sys.getobjects(0)
list.  The object happened to be False.  Now False is in the list, along
with other popular & previously missing leak candidates (like None).
Alas, we still don't have a choke point covering *all* Python objects,
so the list of all objects may still be incomplete.
2003-03-23 17:52:28 +00:00
Tim Peters bf9b24464e slot_sq_contains(): This leaked a reference to the result of calling
__contains__().

Bugfix candidate.
2003-03-23 05:35:36 +00:00
Tim Peters 36eb4dfb81 Refactored some of the Py_TRACE_REFS code. New private API function
_Py_AddToAllObjects() that simply inserts an object at the front of
the doubly-linked list of all objects.  Changed PyType_Ready() (the
 closest thing we've got to a choke point for type objects) to call
that.
2003-03-23 03:33:13 +00:00
Tim Peters 3e40c7ff5b Oops! Used a wrong preprocessor symbol. 2003-03-23 03:04:32 +00:00
Tim Peters 78be7993b6 When Py_TRACE_REFS is defined, a list of all live objects is maintained in
a doubly-linked list, exposed by sys.getobjects().  Unfortunately, it's not
really all live objects, and it seems my fate to bump into programs where
sys.gettotalrefcount() keeps going up but where the reference leaks aren't
accounted for by anything in the list of all objects.

This patch helps a little:  if COUNT_ALLOCS is also defined, from now on
type objects will also appear in this list, provided at least one object
of a type has been allocated.
2003-03-23 02:51:01 +00:00
Tim Peters f1ed934278 _PyFloat_Pack4(): Removed needless call of floor(). 2003-03-21 17:10:03 +00:00
Tim Peters 9905b943f7 New private API functions _PyFloat_{Pack,Unpack}(4,8}. This is a
refactoring to get all the duplicates of this delicate code out of the
cPickle and struct modules.
2003-03-20 20:53:32 +00:00
Raymond Hettinger 1da1dbf458 Renamed PyObject_GenericGetIter to PyObject_SelfIter
to more accurately describe what the function does.

Suggested by Thomas Wouters.
2003-03-17 19:46:11 +00:00
Raymond Hettinger 0153826964 Created PyObject_GenericGetIter().
Factors out the common case of returning self.
2003-03-17 08:24:35 +00:00
Raymond Hettinger 83245b5828 SF bug #699934: Obscure error message
Clarify error message for mro conflicts.
2003-03-12 04:25:42 +00:00