Commit Graph

339 Commits

Author SHA1 Message Date
Michael W. Hudson 02ff6a9952 A slight change to SET_LINENO-less tracing.
This makes things a touch more like 2.2.  Read the comments in
Python/ceval.c for more details.
2002-09-11 15:36:32 +00:00
Skip Montanaro 99dba27e9a Bump default check interval to 100 instructions. Computers are much faster
than when this interval was first established.  Checking too frequently just
adds needless overhead because most of the time there is nothing to do and
no other threads ready to run.
2002-09-03 20:19:06 +00:00
Skip Montanaro d581d7792b replace thread state objects' ticker and checkinterval fields with two
globals, _Py_Ticker and _Py_CheckInterval.  This also implements Jeremy's
shortcut in Py_AddPendingCall that zeroes out _Py_Ticker.  This allows the
test in the main loop to only test a single value.

The gory details are at

    http://python.org/sf/602191
2002-09-03 20:10:45 +00:00
Michael W. Hudson 53d58bb369 Further SET_LINENO reomval fixes. See comments in patch #587933.
Use a slightly different strategy to determine when not to call the line
trace function.  This removes the need for the RETURN_NONE opcode, so
that's gone again.  Update docs and comments to match.

Thanks to Neal and Armin!

Also add a test suite.  This should have come with the original patch...
2002-08-30 13:09:51 +00:00
Guido van Rossum 86c659a329 The error messages in err_args() -- which is only called when the
required number of args is 0 or 1 -- were reversed.  Also change "1"
into "exactly one", the same words as used elsewhere for this
condition.
2002-08-23 14:11:35 +00:00
Michael W. Hudson c230b0e1f9 Comment typo repair. 2002-08-20 15:43:16 +00:00
Michael W. Hudson 62897c5c13 My patch #597221. Use f_lasti more consistently. 2002-08-20 15:19:14 +00:00
Guido van Rossum d8dbf847b6 Add a warning comment to the LOAD_GLOBAL inline code. 2002-08-19 21:17:53 +00:00
Guido van Rossum 3a4dfc87e6 Another ugly inlining hack, expanding the two PyDict_GetItem() calls
in LOAD_GLOBAL.  Besides saving a C function call, it saves checks
whether f_globals and f_builtins are dicts, and extracting and testing
the string object's hash code is done only once.  We bail out of the
inlining if the name is not exactly a string, or when its hash is -1;
because of interning, neither should ever happen.  I believe interning
guarantees that the hash code is set, and I believe that the 'names'
tuple of a code object always contains interned strings, but I'm not
assuming that -- I'm simply testing hash != -1.

On my home machine, this makes a pystone variant with new-style
classes and slots run at the same speed as classic pystone!  (With
new-style classes but without slots, it is still a lot slower.)
2002-08-19 20:24:07 +00:00
Jeremy Hylton 192690e2d2 Inline fast_cfunction() in new call_function().
Also, don't handle METH_OLDARGS on the fast path.  All the interesting
builtins have been converted to use METH_NOARGS, METH_O, or
METH_VARARGS.

Result is another 1-2% speedup.  If I can cobble together 10 of these,
it might make a difference.
2002-08-16 18:36:11 +00:00
Jeremy Hylton e8c0432403 Move body of CALL_FUNCTION opcode into helper function.
This makes the code much easier to ready, because it is at a sane
indentation level.  On my box this shows a 1-2% speedup, which means
nothing, except that I'm not going to worry about the performance
effects of the change.
2002-08-16 17:47:26 +00:00
Guido van Rossum c13f724af0 Streamline the fast track for CFunction calls a bit more: there was
nothing special done if keyword arguments were present, so test for
that earlier and fall through to the normal case if there are any.
This ought to slow down CFunction calls with keyword args, but I don't
care; it's a tiny (1%) improvement for pystone.
2002-08-16 16:14:00 +00:00
Michael W. Hudson dd32a91cc0 This is my patch
[ 587993 ] SET_LINENO killer

Remove SET_LINENO.  Tracing is now supported by inspecting co_lnotab.

Many sundry changes to document and adapt to this change.
2002-08-15 14:59:02 +00:00
Fred Drake 72bc456403 Add weakref support generator-iterators.
Part of fixing SF bug #591704.
2002-08-09 18:35:52 +00:00
Skip Montanaro 496e6581e1 get rid of GETNAMEV macro - use GETITEM directly
same idea as getting rid of GETCONST & GETNAME (see patch #506436)
2002-08-06 17:47:40 +00:00
Skip Montanaro 04d80f87d7 small speedup for constant and name access
see sf #506436
2002-08-04 21:03:35 +00:00
Guido van Rossum 04e7032c6e SF patch 552161 - Py_AddPendingCall doesn't unlock on fail (Daniel
Dunbar)

Can't test this, but looks correct to me.
2002-07-17 16:57:13 +00:00
Tim Peters 0c32279626 Removed more stray instances of statichere, but left _sre.c alone. 2002-07-17 16:49:03 +00:00
Jeremy Hylton 938ace69a0 staticforward bites the dust.
The staticforward define was needed to support certain broken C
compilers (notably SCO ODT 3.0, perhaps early AIX as well) botched the
static keyword when it was used with a forward declaration of a static
initialized structure.  Standard C allows the forward declaration with
static, and we've decided to stop catering to broken C compilers.  (In
fact, we expect that the compilers are all fixed eight years later.)

I'm leaving staticforward and statichere defined in object.h as
static.  This is only for backwards compatibility with C extensions
that might still use it.

XXX I haven't updated the documentation.
2002-07-17 16:30:39 +00:00
Tim Peters a64295b43a There's no need for generators to define an explicit next() method. 2002-07-17 00:15:22 +00:00
Neal Norwitz a81d220625 SF patch # 580411, move frame macros from frameobject.h into ceval.c
remove unused macros
use co alias instead of f->f_code in macros
2002-07-14 00:27:26 +00:00
Jeremy Hylton 76c81eecfa Don't stomp on an exception set by PyCell_Get() 2002-07-11 16:56:38 +00:00
Michael W. Hudson cb4d7ce7cb Now FOR_LOOP is gone, loop_subscript can go too.
make -s rules :-)
2002-06-14 13:53:29 +00:00
Guido van Rossum fea59e7f76 The opcode FOR_LOOP no longer exists. 2002-06-13 17:59:51 +00:00
Guido van Rossum c5fe5eb8d2 SF bug 567538: Generator can crash the interpreter (Finn Bock).
This was a simple typo.  Strange that the compiler didn't catch it!
Instead of WHY_CONTINUE, two tests used CONTINUE_LOOP, which isn't a
why_code at all, but an opcode; but even though 'why' is declared as
an enum, comparing it to an int is apparently not even worth a
warning -- not in gcc, and not in VC++. :-(

Will fix in 2.2 too.
2002-06-12 03:45:21 +00:00
Michael W. Hudson d95c828307 Fix for
[ 558249 ] softspace vs --disable-unicode

And #endif was in the wrong place.

Bugfix candidate, almost surely.

I think I will embark on squashing test failures in --disable-unicode builds --
a Real Bug was hiding under them.
2002-05-20 13:56:11 +00:00
Tim Peters afb2c80b29 ceval.c/do_raise(): Tighten the test to disallow raising an instance of
a str subclass.

test_descr.py/string_exceptions():  New sub-test.

For 2.3 only.  Guido doesn't want this backported.
2002-04-18 18:06:20 +00:00
Guido van Rossum cfbf1a33c1 Fix an issue that was reported in but unrelated to the main problem of
SF bug 535905 (Evil Trashcan and GC interaction).

The SETLOCAL() macro should not DECREF the local variable in-place and
then store the new value; it should copy the old value to a temporary
value, then store the new value, and then DECREF the temporary value.
This is because it is possible that during the DECREF the frame is
accessed by other code (e.g. a __del__ method or gc.collect()) and the
variable would be pointing to already-freed memory.

BUGFIX CANDIDATE!
2002-03-28 20:17:52 +00:00
Tim Peters 8e5fd53be0 SF bug 480215: softspace confused in nested print
This fixes the symptom, but PRINT_ITEM has no way to know what (if
anything) PyFile_WriteObject() writes unless the object being printed
is a string.  When the object isn't a string, this fix retains the
guess that softspace should be set after PyFile_WriteObject().
We might want to say that it's the job of filelike-object write methods
to leave the file's softspace in the correct state.  That would probably
be better -- but everyone relies on PRINT_ITEM to guess for them now.
2002-03-24 19:25:00 +00:00
Neil Schemenauer c24ea08644 Disable the parser hacks that enabled the "yield" keyword using a future
statement.
2002-03-22 23:53:36 +00:00
Neil Schemenauer 08de92a267 Re-enable GC of generator objects. 2002-03-18 20:45:09 +00:00
Neil Schemenauer 6354386d65 Move some opcodes to top of big eval_frame switch statement. Skip
things_to_do block for a few common opcodes that don't do any real
work.  Closes SF patch #512256.
2002-02-17 19:10:14 +00:00
Tim Peters 373f8d81ff LOAD_FAST: rearrange branches to favor the expected case, and get
rid of a redundant NULL-pointer check in the expected case.
2002-02-12 04:31:21 +00:00
Martin v. Löwis 7198a525f3 Patch #494783: Rename cmp_op enumerators. 2002-01-01 19:59:11 +00:00
Tim Peters 54b11918be SF bug #496549 -Qnew and in-place division "/=".
eval_frame():  Under -Qnew, INPLACE_DIVIDE wasn't getting handed off to
INPLACE_TRUE_DIVIDE (like BINARY_DIVIDE was getting handed off to
BINARY_TRUE_DIVIDE).

Bugfix candidate.
2001-12-25 18:49:11 +00:00
Tim Peters b6d14daa1c SF bug #494668: PUSH() should assert-fail on overflow.
eval_frame():  Added asserts to the top of the eval loop, to verify
that the eval stack pointer is in bounds, plus some comments.
2001-12-19 04:11:07 +00:00
Martin v. Löwis 8d3ce5a6b3 Patch #494384: Disable more Unicode API if Unicode is not used. 2001-12-18 22:36:40 +00:00
Tim Peters b519638d1e _PyEval_SliceIndex(): explain why a NULL argument is allowed (thanks
to Guido for the revelation).
2001-12-16 19:44:20 +00:00
Tim Peters cb479e78e0 _PyEval_SliceIndex(): Repaired the comments, and added XXX comments
about its dubious treatment of NULL (also opened a bug report on that,
but don't want to risk changing it this late in the 2.2 game).
2001-12-16 19:11:44 +00:00
Jeremy Hylton 733c8935f9 Fix for SF bug [ #492403 ] exec() segfaults on closure's func_code
Based on the patch from Danny Yoo.  The fix is in exec_statement() in
ceval.c.

There are also changes to introduce use of PyCode_GetNumFree() in
several places.
2001-12-13 19:51:56 +00:00
Guido van Rossum 35974fbf31 Fix for SF bug #489671 (Neil Norwitz): memory leak in test_richcmp.
Had nothing to do with rich comparisons -- some stack cleanup code was
lost as a result of merging in Neil Schemenauer's generators patch.
Reinserted the stack cleanup code, skipping it when yielding.
2001-12-06 21:28:18 +00:00
Guido van Rossum 2556f2e1e2 Fix a typo (probably caused by autocompletion <blush>) that caused a
leak when a class defined a __metaclass__.  This fixes the problem
reported on python-dev by Ping; I dunno if it's the same as SF bug
#489669 (since that mentions Unicode).
2001-12-06 14:09:56 +00:00
Tim Peters 3caca2326e SF bug #488514: -Qnew needs work
Big Hammer to implement -Qnew as PEP 238 says it should work (a global
option affecting all instances of "/").

pydebug.h, main.c, pythonrun.c:  define a private _Py_QnewFlag flag, true
iff -Qnew is passed on the command line.  This should go away (as the
comments say) when true division becomes The Rule.  This is
deliberately not exposed to runtime inspection or modification:  it's
a one-way one-shot switch to pretend you're using Python 3.

ceval.c:  when _Py_QnewFlag is set, treat BINARY_DIVIDE as
BINARY_TRUE_DIVIDE.

test_{descr, generators, zipfile}.py:  fiddle so these pass under
-Qnew too.  This was just a matter of s!/!//! in test_generators and
test_zipfile.  test_descr was trickier, as testbinop() is passed
assumptions that "/" is the same as calling a "__div__" method; put
a temporary hack there to call "__truediv__" instead when the method
name is "__div__" and 1/2 evaluates to 0.5.

Three standard tests still fail under -Qnew (on Windows; somebody
please try the Linux tests with -Qnew too!  Linux runs a whole bunch
of tests Windows doesn't):
    test_augassign
    test_class
    test_coercion
I can't stay awake longer to stare at this (be my guest).  Offhand
cures weren't obvious, nor was it even obvious that cures are possible
without major hackery.

Question:  when -Qnew is in effect, should calls to __div__ magically
change into calls to __truediv__?  See "major hackery" at tail end of
last paragraph <wink>.
2001-12-06 06:23:26 +00:00
Guido van Rossum 354797ccad Fix the final two issues in Armin Rigo's SF bug #488477: apply_slice()
and assign_slice() weren't properly DECREF'ing the temporary slice
object they created.  (Shame on me. :-)
2001-12-03 19:45:06 +00:00
Guido van Rossum bb8f59a371 unpack_iterable(): Add a missing DECREF in an error case. Reported by
Armin Rigo (SF bug #488477).  Added a testcase to test_unpack_iter()
in test_iter.py.
2001-12-03 19:33:25 +00:00
Tim Peters b13680bf03 SF bug #483469: crash on unbounded recursion in __del__.
PyEval_EvalCodeEx():  increment tstate->recursion_depth around the
decref of the frame, because the C stack for this call is still in
use and the decref can lead to __del__ methods getting called.

While this gives tstate->recursion_depth a value proportional to the
depth of the C stack (instead of a small constant no matter how
deeply __del__s recurse), it's not enough to stop the reported crash
when using the default recursion limit on Windows.

Bugfix candidate.
2001-11-27 23:29:29 +00:00
Marc-André Lemburg 0c4d8d05a8 Fix for bug #480188: printing unicode objects 2001-11-20 15:17:25 +00:00
Marc-André Lemburg 4962fc8fed Backing out the fast path for interned string compares again as requested. 2001-11-08 08:34:43 +00:00
Marc-André Lemburg c52d713b7a Add fast-path for comparing interned (true) string objects.
This patch boosts performance for comparing identical string object
by some 20% on my machine while not causing any noticable slow-down
for other operations (according to tests done with pybench).
2001-11-07 14:54:49 +00:00
Tim Peters 6e6a63f01c SF Patch (but with no patch) 472555 Remove trailing common in enumeration.
Some AIX compiler didn't like the trailing comma at the end of the
why_code enum decl.
2001-10-18 20:49:35 +00:00