Commit Graph

19951 Commits

Author SHA1 Message Date
Fred Drake 7c0a93d966 Updated to reflect the rationalized profiler event reporting. 2001-10-04 14:49:46 +00:00
Fred Drake 8f51f54319 Rationalize the events passed to the profiler (no changes for the tracer).
The profiler does not need to know anything about the exception state,
so we no longer call it when an exception is raised.  We do, however,
make sure we *always* call the profiler when we exit a frame.  This
ensures that timing events are more easily isolated by a profiler and
finally clauses that do a lot of work don't have their time
mis-allocated.

When an exception is propogated out of the frame, the C callback for
the profiler now receives a PyTrace_RETURN event with an arg of NULL;
the Python-level profile hook function will see a 'return' event with
an arg of None.  This means that from Python it is impossible for the
profiler to determine if the frame exited with an exception or if it
returned None, but this doesn't matter for profiling.  A C-based
profiler could tell the difference, but this doesn't seem important.

ceval.c:eval_frame():  Simplify the code in two places so that the
                       profiler is called for every exit from a frame
                       and not for exceptions.

sysmodule.c:profile_trampoline():  Make sure we don't expose Python
                                   code to NULL; use None instead.
2001-10-04 14:48:42 +00:00
Guido van Rossum c4b09b4417 Add note about profile fix. 2001-10-04 10:19:00 +00:00
Tim Peters 3899d74c10 Make clear that tuple() accepts the same kind of arguments as list(). 2001-10-04 06:53:20 +00:00
Tim Peters 1c9ca8726e Added a little type/class NEWS. 2001-10-04 06:43:12 +00:00
Tim Peters c59fb2d230 This test relied on hard tab characters, so failed after whitespace
normalization.  Now uses \t in strings instead of hard tabs.
2001-10-04 06:26:17 +00:00
Tim Peters 4fb1fe8bd2 class_docstrings(): The new-style class tests should use new-style
classes (sheesh!).
2001-10-04 05:48:13 +00:00
Tim Peters 59f809d3bc type_new(): cast PyObject_MALLOC's result to char*, for clarity. 2001-10-04 05:43:02 +00:00
Tim Peters 527e64fd68 Whitespace normalization. 2001-10-04 05:36:56 +00:00
Tim Peters 2f93e28a19 SF bug [#467331] ClassType.__doc__ always None.
For a dynamically constructed type object, fill in the tp_doc slot with
a copy of the argument dict's "__doc__" value, provided the latter exists
and is a string.
NOTE:  I don't know what to do if it's a Unicode string, so in that case
tp_doc is left NULL (which shows up as Py_None if you do Class.__doc__).
Note that tp_doc holds a char*, not a general PyObject*.
2001-10-04 05:27:00 +00:00
Guido van Rossum f137f75ab8 Hopefully fix the profiler right. Add a test suite that checks that
it deals correctly with some anomalous cases; according to this test
suite I've fixed it right.

The anomalous cases had to do with 'exception' events: these aren't
generated when they would be most helpful, and the profiler has to
work hard to recover the right information.  The problems occur when C
code (such as hasattr(), which is used as the example here) calls back
into Python code and clears an exception raised by that Python code.
Consider this example:

    def foo():
        hasattr(obj, "bar")

Where obj is an instance from a class like this:

    class C:
        def __getattr__(self, name):
            raise AttributeError

The profiler sees the following sequence of events:

    call (foo)
    call (__getattr__)
    exception (in __getattr__)
    return (from foo)

Previously, the profiler would assume the return event returned from
__getattr__. An if statement checking for this condition and raising
an exception was commented out...  This version does the right thing.
2001-10-04 00:58:24 +00:00
Fred Drake 6f3d82693a Expand the documentation of the low-level tracing/profiling interface.
This reflects what is currently in CVS, which may change before 2.2 is final.
2001-10-03 21:52:51 +00:00
Fred Drake 0099ba73de Add some more test cases to be sure we do the right thing in various cases. 2001-10-03 21:15:32 +00:00
Fred Drake a0bc9993e7 Undo previous patch; it did not quite work out. 2001-10-03 21:12:32 +00:00
Greg Ward 57fc21018f Fix a spelling error that has been bugging me for longer than I care to admit. 2001-10-03 19:59:30 +00:00
Andrew M. Kuchling 4602c1b702 Set .addr in a few more places (patch approved by Sam Rushing) 2001-10-03 17:07:25 +00:00
Guido van Rossum 4a5a2bc2b6 dynamics(): add a dummy __getattr__ method to the C class so that the
test for modifying __getattr__ works, now that slot_tp_getattr_hook
zaps the slot if there's no hook.  Added an XXX comment with a ref
back to slot_tp_getattr_hook.
2001-10-03 13:59:54 +00:00
Guido van Rossum 1e1de1cf35 typeobject.c, slot_tp_gettattr_hook(): fix the speedup hack -- the
test for getattribute==NULL was bogus because it always found
object.__getattribute__.  Pick it apart using the trick we learned
from slot_sq_item, and if it's just a wrapper around
PyObject_GenericGetAttr, zap it.  Also added a long XXX comment
explaining the consequences.
2001-10-03 13:58:35 +00:00
Skip Montanaro ae3b1258e4 remove empty __del__ method from BaseRequestHandler to avoid cyclic garbage
loss for no reason.
2001-10-03 12:21:23 +00:00
Guido van Rossum f4593e0b65 *EXPERIMENTAL* speedup of slot_sq_item. This sped up the following
test dramatically:

    class T(tuple): __dynamic__ = 1
    t = T(range(1000))
    for i in range(1000): tt = tuple(t)

The speedup was about 5x compared to the previous state of CVS (1.7
vs. 8.8, in arbitrary time units).  But it's still more than twice as
slow as as the same test with __dynamic__ = 0 (0.8).

I'm not sure that I really want to go through the trouble of this kind
of speedup for every slot.  Even doing it just for the most popular
slots will be a major effort (the new slot_sq_item is 40+ lines, while
the old one was one line with a powerful macro -- unfortunately the
speedup comes from expanding the macro and doing things in a way
specific to the slot signature).

An alternative that I'm currently considering is sketched in PLAN.txt:
trap setattr on type objects.  But this will require keeping track of
all derived types using weak references.
2001-10-03 12:09:30 +00:00
Tim Peters 1b0e5490c5 Made the classmethod docstring test a bit less trivial. 2001-10-03 04:15:28 +00:00
Tim Peters 17111f3b24 SF bug [#467336] doctest failures w/ new-style classes.
Taught doctest about static methods, class methods, and property docstrings
in new-style classes.  As for inspect.py/pydoc.py before it, the new stuff
needed didn't really fit into the old architecture (but was less of a
strain to force-fit here).
New-style class docstrings still aren't found, but that's the subject
of a different bug and I want to fix that right instead of hacking around
it in doctest.
2001-10-03 04:08:26 +00:00
Guido van Rossum f49a91340a Mark treatment of binary operators for __rop__-before-__op__ as done.
Add more detail about the speed optimizations needed for __dynamic__.
The weak reference solution becomes more attractive...
2001-10-03 03:00:56 +00:00
Guido van Rossum da21c0110b call_method(), call_maybe(): fix a performance bug: the argument
pointing to a static variable to hold the object form of the string
was never used, causing endless calls to PyString_InternFromString().
One particular test (with lots of __getitem__ calls) became a third
faster with this!
2001-10-03 00:50:18 +00:00
Guido van Rossum ed554f6fc7 Note removal of Demo/dns, point to PyDNS. 2001-10-02 23:15:37 +00:00
Guido van Rossum 2559f5a73b Removed Demo/dns -- see sf.net/projects/pydns/ instead. 2001-10-02 23:13:16 +00:00
Tim Peters 4a9ac4a83c SF patch [#466616] Exclude imported items from doctest.
Another installment; the new functionality wasn't actually enabled in
normal use, only in the strained use checked by the test case.
2001-10-02 22:47:08 +00:00
Tim Peters c15c4f1f39 SF bug [#467265] Compile errors on SuSe Linux on IBM/s390.
Unknown whether this fixes it.
- stringobject.c, PyString_FromFormatV:  don't assume that va_list is of
  a type that can be copied via an initializer.
- errors.c, PyErr_Format:  add a va_end() to balance the va_start().
2001-10-02 21:32:07 +00:00
Guido van Rossum 048eb75c2d Add Garbage Collection support to new-style classes (not yet to their
instances).

Also added GC support to various auxiliary types: super, property,
descriptors, wrappers, dictproxy.  (Only type objects have a tp_clear
field; the other types are.)

One change was necessary to the GC infrastructure.  We have statically
allocated type objects that don't have a GC header (and can't easily
be given one) and heap-allocated type objects that do have a GC
header.  Giving these different metatypes would be really ugly: I
tried, and I had to modify pickle.py, cPickle.c, copy.py, add a new
invent a new name for the new metatype and make it a built-in, change
affected tests...  In short, a mess.  So instead, we add a new type
slot tp_is_gc, which is a simple Boolean function that determines
whether a particular instance has GC headers or not.  This slot is
only relevant for types that have the (new) GC flag bit set.  If the
tp_is_gc slot is NULL (by far the most common case), all instances of
the type are deemed to have GC headers.  This slot is called by the
PyObject_IS_GC() macro (which is only used twice, both times in
gcmodule.c).

I also changed the extern declarations for a bunch of GC-related
functions (_PyObject_GC_Del etc.): these always exist but objimpl.h
only declared them when WITH_CYCLE_GC was defined, but I needed to be
able to reference them without #ifdefs.  (When WITH_CYCLE_GC is not
defined, they do the same as their non-GC counterparts anyway.)
2001-10-02 21:24:57 +00:00
Tim Peters 0481d24dd5 CVS patch [#466628] Doc changes for doctest patch (#466616), from
Tim Hochberg.  Doctest no longer searches imported objects.
2001-10-02 21:01:22 +00:00
Guido van Rossum fe1fd0e6e9 pickles():
- The test for deepcopy() in pickles() was indented wrongly, so it got
  run twice (one for binary pickle mode, one for text pickle mode; but
  the test doesn't depend on the pickle mode).

- In verbose mode, show which subtest (pickle/cPickle/deepcopy, text/bin).
2001-10-02 19:58:32 +00:00
Guido van Rossum c907bd89de The error reporting here was a bit sparse. In verbose mode, the code
in run_test() referenced two non-existent variables, and in
non-verbose mode, the tests didn't report the actual number, when it
differed from the expected number.  Fixed this.

Also added an extra call to gc.collect() at the start of test_all().
This will be needed when I check in the changes to add GC to new-style
classes.
2001-10-02 19:49:47 +00:00
Guido van Rossum b855134a0d Under certain conditions (sometimes triggered by the test suite),
"from xml.parsers import expat" succeeds but the imported expat module
is an empty shell.  Make sure we don't be fooled by that.
2001-10-02 18:33:11 +00:00
Guido van Rossum e37e96df06 Correct the URL for the license (only used when the LICENSE[.txt] file
is not found).  Being fancy: insert the first 3 characters of
sys.version in the URL.
2001-10-02 18:27:09 +00:00
Guido van Rossum 0e58ff8de8 Update reference to pydns. 2001-10-02 13:05:41 +00:00
Tim Peters 7402f791a4 SF patch [#466616] Exclude imported items from doctest,
from Tim Hochberg.  Also mucho fiddling to change the way doctest
determines whether a thing is a function, module or class.  Under 2.2,
this really requires the functions in inspect.py (e.g., types.ClassType
is close to meaningless now, if not outright misleading).
2001-10-02 03:53:41 +00:00
Fred Drake d90f509b8f Fredrik tells me the truefalse parameter for boolean() is not part of the
public interface, so we can simplify the documentation.
2001-10-01 21:05:30 +00:00
Tim Peters 1350c07de3 Removed stray backslash (a typo -- my fault). 2001-10-01 20:25:26 +00:00
Tim Peters 20524dbf36 The description of dictionary comparison was out of date. Rather than
try to explain the complex general scheme we actually use now, I decided
to spell out only what equality means (which is easy to explain and
intuitive), leaving the other outcomes unspecified beyond consistency.
2001-10-01 20:22:45 +00:00
Tim Peters 092a7a80fd SF patch [#466353] Py_HUGE_VAL on BeOS for Intel.
The patch repaired internal gcc compiler errors on BeOS.
This checkin repairs them in a simpler way, by explicitly casting the
platform INFINITY to double.
2001-10-01 19:50:06 +00:00
Fredrik Lundh 1538c23dec restored 1.5.2 compatibility
added local escape method (made the dumps method some 50-80% faster)
minor tweaks to the unmarshalling code
2001-10-01 19:42:03 +00:00
Tim Peters 1ce3cf7749 SF patch [#466877] SIGBREAK is missing from signal module.
Patch from Steve Scott to add SIGBREAK support (unique to Windows).
2001-10-01 17:58:40 +00:00
Skip Montanaro fbacaf7298 approximately double dump performance by moving import of cgi.escape back to
top level.
2001-10-01 17:50:29 +00:00
Skip Montanaro 419abdaff2 simple dumps/loads test case for xmlrpclib 2001-10-01 17:47:44 +00:00
Guido van Rossum 55f2099b2f Miscellaneous code fiddling:
- SLOT1BINFULL() macro: changed this to check for __rop__ overriding
  __op__, like binary_op1() in abstract.c -- the latter only calls the
  slot function once if both types use the same slot function, so the
  slot function must make both calls -- which it already did for the
  __op__, __rop__ order, but not yet for the __rop__, __op__ order
  when B.__class__ is a subclass of A.__class__.

- slot_sq_contains(), slot_nb_nonzero(): use lookup_maybe() rather
  than lookup_method() which sets an exception which we then clear.

- slot_nb_coerce(): don't give up when left argument's __coerce__
returns NotImplemented, but give the right argument a chance.
2001-10-01 17:18:22 +00:00
Guido van Rossum 89c4264792 binary_op1(), ternary_op(): rearrange the code so that slotw is tested
(to see whether __rop__ should go before __op__) only when slotv is
set.  This saves a test+branch when only slotw is set.
2001-10-01 17:10:18 +00:00
Fred Drake 6c81e2a44f "boolean" --> "Boolean" (per the style guide). 2001-10-01 17:04:10 +00:00
Fred Drake 0f0380a25f Fix some minor style-guide conformance bugs. 2001-10-01 17:04:10 +00:00
Martin v. Löwis 5868fb8df1 Undo last checkin. 2001-10-01 17:04:03 +00:00
Fred Drake fe95e65668 Straighten out some markup.
"boolean" --> "Boolean" (per the style guide).
2001-10-01 17:03:48 +00:00