Commit Graph

681 Commits

Author SHA1 Message Date
Nick Coghlan c40bc09942 Issue #13783: the PEP 380 implementation no longer expands the public C API 2012-06-17 15:15:49 +10:00
Benjamin Peterson d1ab6089ff check return for error 2012-06-01 11:18:22 -07:00
Benjamin Peterson d5a1c44455 PEP 415: Implement suppression of __context__ display with an exception attribute
This replaces the original PEP 409 implementation. See #14133.
2012-05-14 22:09:31 -07:00
Benjamin Peterson 1138944888 only incref when using borrowing functions 2012-04-26 00:26:37 -04:00
Benjamin Peterson 7d95e40721 Implement PEP 412: Key-sharing dictionaries (closes #13903)
Patch from Mark Shannon.
2012-04-23 11:24:50 -04:00
Antoine Pitrou bf35c156b4 Fix refleak: PyObject_GetItem returns a new reference, not a borrowed one like PyDict_GetItem. 2012-04-19 18:21:04 +02:00
Victor Stinner b0b224233e Issue #14385: Support other types than dict for __builtins__
It is now possible to use a custom type for the __builtins__ namespace, instead
of a dict. It can be used for sandboxing for example.  Raise also a NameError
instead of ImportError if __build_class__ name if not found in __builtins__.
2012-04-19 00:57:45 +02:00
Brett Cannon 368b4b7405 Guard an LLTRACE variable to silence an unused variable warning. 2012-04-02 12:17:59 -04:00
Victor Stinner 3c1e48176e Issue #14383: Add _PyDict_GetItemId() and _PyDict_SetItemId() functions
These functions simplify the usage of static constant Unicode strings.
Generalize the usage of _Py_Identifier in ceval.c and typeobject.c.
2012-03-26 22:10:51 +02:00
Benjamin Peterson 302e7902c8 use identifier api 2012-03-20 23:17:04 -04:00
Benjamin Peterson 2afe6aeae8 perform yield from delegation by repeating YIELD_FROM opcode (closes #14230)
This allows generators that are using yield from to be seen by debuggers. It
also kills the f_yieldfrom field on frame objects.

Patch mostly from Mark Shannon with a few tweaks by me.
2012-03-15 15:37:39 -05:00
Nick Coghlan ab7bf2143e Close issue #6210: Implement PEP 409 2012-02-26 17:49:52 +10:00
Benjamin Peterson ce79852077 use the static identifier api for looking up special methods
I had to move the static identifier code from unicodeobject.h to object.h in
order for this to work.
2012-01-22 11:24:29 -05:00
Amaury Forgeot d'Arc 0a239e9191 Fix compilation with C89 compilers (Windows...) 2012-01-13 21:08:49 +01:00
Benjamin Peterson 0296a56520 NULL and no exception set from tp_iternext means StopIteration 2012-01-13 14:54:31 -05:00
Nick Coghlan 1f7ce62bd6 Implement PEP 380 - 'yield from' (closes #11682) 2012-01-13 21:43:40 +10:00
Antoine Pitrou 86a36b500a PEP 3155 / issue #13448: Qualified name for classes and functions. 2011-11-25 18:56:07 +01:00
Martin v. Löwis 1c67dd9b15 Port SetAttrString/HasAttrString to SetAttrId/GetAttrId. 2011-10-14 15:16:45 +02:00
Martin v. Löwis bd928fef42 Rename _Py_identifier to _Py_IDENTIFIER. 2011-10-14 10:20:37 +02:00
Martin v. Löwis afe55bba33 Add API for static strings, primarily good for identifiers.
Thanks to Konrad Schöbel and Jasper Schulz for helping with the mass-editing.
2011-10-09 10:38:36 +02:00
Victor Stinner d2a915dbf6 ceval.c: restore str+=str optimization 2011-10-02 20:34:20 +02:00
Benjamin Peterson 811c2f1369 remove "fast-path" for (i)adding strings
These were just an artifact of the old unicode concatenation hack and likely
just penalized other kinds of adding. Also, this fixes __(i)add__ on string
subclasses.
2011-09-30 21:31:21 -04:00
Victor Stinner bec0fda264 Remove commented code: str+=str is no more super-optimized 2011-10-01 01:26:08 +02:00
Martin v. Löwis d63a3b8beb Implement PEP 393. 2011-09-28 07:41:54 +02:00
Charles-François Natali f23339a7bb Issue 12620: Make pendingbusy flag static to Py_MakePendingCalls(). 2011-07-23 18:15:43 +02:00
Benjamin Peterson 76f7f4d979 excise the remains of STOP_CODE, which hasn't done anything useful for years 2011-07-17 22:49:50 -05:00
Benjamin Peterson e92cd0ce98 merge 3.2 (#11627) 2011-07-15 14:10:35 -05:00
Benjamin Peterson 5afa03a72e catch nasty exception classes with __new__ that doesn't return a exception (closes #11627)
Patch from Andreas Stührk.
2011-07-15 14:09:26 -05:00
Benjamin Peterson 9bfd0dee9b no one passes NULL here (or should anyway) 2011-07-03 17:06:32 -05:00
Benjamin Peterson 878802435d convert generator exc state functions into static functions 2011-07-03 16:48:31 -05:00
Benjamin Peterson 536feac7f8 merge 3.2 2011-07-03 16:27:41 -05:00
Benjamin Peterson ac91341333 never retain a generator's caller's exception state on the generator after a yield/return
This requires some trickery to properly save the exception state if the
generator creates its own exception state.
2011-07-03 16:25:11 -05:00
Benjamin Peterson 7b7099c36f merge 3.2 (#12475) 2011-07-03 13:48:36 -05:00
Benjamin Peterson 83195c3f0c restore a generator's caller's exception state both on yield and (last) return
This prevents generator exception state from leaking into the caller.

Closes #12475.
2011-07-03 13:44:00 -05:00
Benjamin Peterson 9003760991 map cells to arg slots at code creation time (closes #12399)
This removes nested loops in PyEval_EvalCodeEx.
2011-06-25 22:54:45 -05:00
Benjamin Peterson e109c70860 give the names of missing positional or keyword-only arguments (closes #12356) 2011-06-24 09:37:26 -05:00
Benjamin Peterson b204a42383 greatly improve argument parsing error messages (closes #12265) 2011-06-05 22:04:07 -05:00
Antoine Pitrou fc20b0c65c Issue #1856: Avoid crashes and lockups when daemon threads run while the
interpreter is shutting down; instead, these threads are now killed when
they try to take the GIL.
2011-05-04 20:04:29 +02:00
Antoine Pitrou 0d5e52d346 Issue #1856: Avoid crashes and lockups when daemon threads run while the
interpreter is shutting down; instead, these threads are now killed when
they try to take the GIL.
2011-05-04 20:02:30 +02:00
Victor Stinner 0a5f65ab0a Issue #7330, #10833: Replace %100s by %.100s and %200s by %.200s
I suppose that the author would like to truncate the type name, not get a
string of 100/200 characters.
2011-03-22 01:09:21 +01:00
Ezio Melotti 3b3499ba69 #11565: Merge with 3.1. 2011-03-16 11:35:38 +02:00
Ezio Melotti 13925008dc #11565: Fix several typos. Patch by Piotr Kasprzyk. 2011-03-16 11:05:33 +02:00
Ezio Melotti b88ed1549e #11565: Merge with 3.2. 2011-03-16 11:38:59 +02:00
Brett Cannon b94767ff44 Issue #8914: fix various warnings from the Clang static analyzer v254. 2011-02-22 20:15:44 +00:00
Victor Stinner ed4c71112a Remove filename variable from ceval.c
Issue #11168: Remove filename debug variable from PyEval_EvalFrameEx().
It encoded the Unicode filename to UTF-8, but the encoding fails on
undecodable filename (on surrogate characters) which raises an unexpected
UnicodeEncodeError on recursion limit.
2011-02-21 21:05:50 +00:00
David Malcolm 8ad4cd90e9 Merged revisions 87796 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r87796 | david.malcolm | 2011-01-06 12:01:36 -0500 (Thu, 06 Jan 2011) | 6 lines

  Issue #10655: Fix the build on PowerPC on Linux with GCC when building with
  timestamp profiling (--with-tsc): the preprocessor test for the PowerPC
  support now looks for "__powerpc__" as well as "__ppc__": the latter seems to
  only be present on OS X; the former is the correct one for Linux with GCC.
........
2011-01-06 17:36:32 +00:00
David Malcolm f1397ad399 Issue #10655: Fix the build on PowerPC on Linux with GCC when building with
timestamp profiling (--with-tsc): the preprocessor test for the PowerPC
support now looks for "__powerpc__" as well as "__ppc__": the latter seems to
only be present on OS X; the former is the correct one for Linux with GCC.
2011-01-06 17:01:36 +00:00
Martin v. Löwis 4d0d471a80 Merge branches/pep-0384. 2010-12-03 20:14:31 +00:00
Georg Brandl e5b99f0fb3 Remove redundant includes of headers that are already included by Python.h. 2010-11-30 09:41:01 +00:00
Benjamin Peterson 8f67d0893f make hashes always the size of pointers; introduce Py_hash_t #9778 2010-10-17 20:54:53 +00:00
Victor Stinner a00064576a ceval.c: catch recursion error on _PyUnicode_AsString(co->co_filename) 2010-10-13 10:48:55 +00:00
Benjamin Peterson aa7fbd9564 revert r85003, poorly considered; breaks tests 2010-09-25 03:25:42 +00:00
Benjamin Peterson 81437c9025 don't count keyword arguments as positional #9943 2010-09-25 03:14:33 +00:00
Antoine Pitrou 1df1536fb9 Issue #9828: Destroy the GIL in Py_Finalize(), so that it gets properly
re-created on a subsequent call to Py_Initialize().  The problem (a crash)
wouldn't appear in 3.1 or 2.7 where the GIL's structure is more trivial.
2010-09-13 14:16:46 +00:00
Benjamin Peterson e208b7c5b1 typo 2010-09-10 23:53:14 +00:00
Benjamin Peterson d0de25d731 use Py_REFCNT 2010-09-10 23:52:42 +00:00
Benjamin Peterson d2be5b4fe4 remove gil_drop_request in --without-threads 2010-09-10 22:47:02 +00:00
Benjamin Peterson 00ebe2cdc4 use DISPATCH() instead of continue 2010-09-10 22:02:31 +00:00
Amaury Forgeot d'Arc ba117ef7e9 #4617: Previously it was illegal to delete a name from the local
namespace if it occurs as a free variable in a nested block.  This limitation
of the compiler has been lifted, and a new opcode introduced (DELETE_DEREF).

This sample was valid in 2.6, but fails to compile in 3.x without this change::

   >>> def f():
   ...     def print_error():
   ...        print(e)
   ...     try:
   ...        something
   ...     except Exception as e:
   ...        print_error()
   ...        # implicit "del e" here


This sample has always been invalid in Python, and now works::

   >>> def outer(x):
   ...     def inner():
   ...        return x
   ...     inner()
   ...     del x

There is no need to bump the PYC magic number: the new opcode is used
for code that did not compile before.
2010-09-10 21:39:53 +00:00
Antoine Pitrou 74a69fa662 Issue #9225: Remove the ROT_FOUR and DUP_TOPX opcode, the latter replaced
by the new (and simpler) DUP_TOP_TWO.  Performance isn't changed, but
our bytecode is a bit simplified.  Patch by Demur Rumed.
2010-09-04 18:43:52 +00:00
Victor Stinner 4a3733d160 Issue #9425: save/restore exception on filename encoding
_PyUnicode_AsString() raises an exception on unencodable filename.
2010-08-17 00:39:57 +00:00
Antoine Pitrou 042b128f58 Issue #9203: Computed gotos are now enabled by default on supported
compilers (which are detected by the configure script).  They can still
be disable selectively by specifying --without-computed-gotos.
2010-08-13 21:15:58 +00:00
Benjamin Peterson 20f9c3c50f revert unintended changes 2010-07-20 22:39:34 +00:00
Benjamin Peterson 013783c529 move test_trace.py so as not to conflict with future tests for the trace module 2010-07-20 22:37:19 +00:00
Georg Brandl 0310a83e7f #3071: tell how many values were expected when unpacking too many. 2010-07-10 10:32:36 +00:00
Benjamin Peterson 88968ad380 only take into account positional arguments count in related error messages 2010-06-25 19:30:21 +00:00
Stefan Krah c87901d56c Merged revisions 82181 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r82181 | stefan.krah | 2010-06-23 20:42:39 +0200 (Wed, 23 Jun 2010) | 3 lines

  Issue #8930: Remaining indentation fixes after the Grand Unified Indenting.
........
2010-06-23 18:54:09 +00:00
Stefan Krah b7e1010096 Issue #8930: Remaining indentation fixes after the Grand Unified Indenting. 2010-06-23 18:42:39 +00:00
Benjamin Peterson 08ec84cf72 use atomic structures in non-thread version 2010-05-30 14:49:32 +00:00
Antoine Pitrou 7f14f0d8a0 Recorded merge of revisions 81032 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k

................
  r81032 | antoine.pitrou | 2010-05-09 17:52:27 +0200 (dim., 09 mai 2010) | 9 lines

  Recorded merge of revisions 81029 via svnmerge from
  svn+ssh://pythondev@svn.python.org/python/trunk

  ........
    r81029 | antoine.pitrou | 2010-05-09 16:46:46 +0200 (dim., 09 mai 2010) | 3 lines

    Untabify C files. Will watch buildbots.
  ........
................
2010-05-09 16:14:21 +00:00
Antoine Pitrou f95a1b3c53 Recorded merge of revisions 81029 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r81029 | antoine.pitrou | 2010-05-09 16:46:46 +0200 (dim., 09 mai 2010) | 3 lines

  Untabify C files. Will watch buildbots.
........
2010-05-09 15:52:27 +00:00
Benjamin Peterson 70cce42f15 read eval_breaker with atomic api with computed gotos 2010-05-03 21:09:59 +00:00
Jeffrey Yasskin 39370830a9 Make (most of) Python's tests pass under Thread Sanitizer.
http://code.google.com/p/data-race-test/wiki/ThreadSanitizer is a dynamic data
race detector that runs on top of valgrind. With this patch, the binaries at
http://code.google.com/p/data-race-test/wiki/ThreadSanitizer#Binaries pass many
but not all of the Python tests. All of regrtest still passes outside of tsan.

I've implemented part of the C1x atomic types so that we can explicitly mark
variables that are used across threads, and get defined behavior as compilers
advance.

I've added tsan's client header and implementation to the codebase in
dynamic_annotations.{h,c} (docs at
http://code.google.com/p/data-race-test/wiki/DynamicAnnotations).
Unfortunately, I haven't been able to get helgrind and drd to give sensible
error messages, even when I use their client annotations, so I'm not supporting
them.
2010-05-03 19:29:34 +00:00
Antoine Pitrou 8689a10f07 Merged revisions 79555 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r79555 | antoine.pitrou | 2010-04-01 18:42:11 +0200 (jeu., 01 avril 2010) | 5 lines

  Issue #8276: PyEval_CallObject() is now only available in macro form.  The
  function declaration, which was kept for backwards compatibility reasons,
  is now removed (the macro was introduced in 1997!).
........
2010-04-01 16:53:15 +00:00
Benjamin Peterson 7588b8b355 nest if for clarity 2010-03-21 21:22:12 +00:00
Benjamin Peterson afcee8b78d count keyword only arguments as part of the total 2010-03-21 21:16:24 +00:00
Benjamin Peterson f3b7a25a21 Merged revisions 78028 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r78028 | benjamin.peterson | 2010-02-06 13:40:18 -0600 (Sat, 06 Feb 2010) | 1 line

  remove pointless error checking
........
2010-03-21 21:12:03 +00:00
Benjamin Peterson 232ecb8918 cleanup a bit 2010-03-21 21:08:54 +00:00
Victor Stinner 38c36f8576 Merged revisions 78875 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r78875 | victor.stinner | 2010-03-12 18:00:41 +0100 (ven., 12 mars 2010) | 5 lines

  Issue #6697: use %U format instead of _PyUnicode_AsString(), because
  _PyUnicode_AsString() was not checked for error (NULL).

  The unicode string is no more truncated to 200 or 400 *bytes*.
........
2010-03-21 21:05:53 +00:00
Benjamin Peterson a567a7796b Merged revisions 79205,79219,79228,79230,79232-79233,79235,79237 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r79205 | benjamin.peterson | 2010-03-21 12:34:54 -0500 (Sun, 21 Mar 2010) | 1 line

  rewrite a bit
........
  r79219 | benjamin.peterson | 2010-03-21 14:24:08 -0500 (Sun, 21 Mar 2010) | 1 line

  flatten condition
........
  r79228 | benjamin.peterson | 2010-03-21 14:35:39 -0500 (Sun, 21 Mar 2010) | 1 line

  remove pointless condition
........
  r79230 | benjamin.peterson | 2010-03-21 14:39:52 -0500 (Sun, 21 Mar 2010) | 1 line

  co_varnames is certainly a tuple, so let's not waste time finding out
........
  r79232 | benjamin.peterson | 2010-03-21 14:54:56 -0500 (Sun, 21 Mar 2010) | 1 line

  fix import
........
  r79233 | benjamin.peterson | 2010-03-21 14:56:37 -0500 (Sun, 21 Mar 2010) | 1 line

  don't write duplicate tests
........
  r79235 | benjamin.peterson | 2010-03-21 15:21:00 -0500 (Sun, 21 Mar 2010) | 4 lines

  improve error message from passing inadequate number of keyword arguments #6474

  Note this removes the "non-keyword" or "keyword" phrases from these messages.
........
  r79237 | benjamin.peterson | 2010-03-21 15:30:30 -0500 (Sun, 21 Mar 2010) | 1 line

  take into account keyword arguments when passing too many args
........
2010-03-21 21:00:50 +00:00
Victor Stinner 3f1af5c42e Issue #6697: use %U format instead of _PyUnicode_AsString(), because
_PyUnicode_AsString() was not checked for error (NULL).

The unicode string is no more truncated to 200 or 400 *bytes*.
2010-03-12 17:00:41 +00:00
Benjamin Peterson d01444d325 Merged revisions 78766 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r78766 | benjamin.peterson | 2010-03-07 11:10:51 -0600 (Sun, 07 Mar 2010) | 1 line

  prevent generator finalization from invalidating sys.exc_info() #7173
........
2010-03-07 17:14:15 +00:00
Benjamin Peterson ae5f2f4a39 prevent generator finalization from invalidating sys.exc_info() #7173 2010-03-07 17:10:51 +00:00
Benjamin Peterson f8b60b20a5 fix comment 2010-02-11 02:31:04 +00:00
Antoine Pitrou 074e5ed974 Merge in the new GIL. 2009-11-10 19:50:40 +00:00
Mark Dickinson ee2dd4a4e3 Merged revisions 75984 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k

................
  r75984 | mark.dickinson | 2009-10-31 10:18:44 +0000 (Sat, 31 Oct 2009) | 12 lines

  Merged revisions 75982 via svnmerge from
  svn+ssh://pythondev@svn.python.org/python/trunk

  ........
    r75982 | mark.dickinson | 2009-10-31 10:11:28 +0000 (Sat, 31 Oct 2009) | 5 lines

    Issue #6603: Fix --with-tsc build failures on x86-64 that resulted
    from a gcc inline assembler peculiarity. (gcc's "A" constraint
    apparently means 'rax or rdx' in 64-bit mode, not edx:eax
    or rdx:rax as one might expect.)
  ........
................
2009-10-31 10:20:38 +00:00
Mark Dickinson a25b1312c9 Merged revisions 75982 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r75982 | mark.dickinson | 2009-10-31 10:11:28 +0000 (Sat, 31 Oct 2009) | 5 lines

  Issue #6603: Fix --with-tsc build failures on x86-64 that resulted
  from a gcc inline assembler peculiarity. (gcc's "A" constraint
  apparently means 'rax or rdx' in 64-bit mode, not edx:eax
  or rdx:rax as one might expect.)
........
2009-10-31 10:18:44 +00:00
Ezio Melotti b4d286d04e silence with (void) two warnings about computed and unused value of POP() 2009-10-03 16:14:07 +00:00
Alexandre Vassalotti bfc3099f38 Merged revisions 73750 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r73750 | benjamin.peterson | 2009-07-01 19:45:19 -0400 (Wed, 01 Jul 2009) | 1 line

  small optimization: avoid popping the current block until we have to
........
2009-07-21 05:23:51 +00:00
Alexandre Vassalotti 7b82b40a47 Merged revisions 72487-72488,72879 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r72487 | jeffrey.yasskin | 2009-05-08 17:51:06 -0400 (Fri, 08 May 2009) | 7 lines

  PyCode_NewEmpty:
  Most uses of PyCode_New found by http://www.google.com/codesearch?q=PyCode_New
  are trying to build an empty code object, usually to put it in a dummy frame
  object. This patch adds a PyCode_NewEmpty wrapper which lets the user specify
  just the filename, function name, and first line number, instead of also
  requiring lots of code internals.
........
  r72488 | jeffrey.yasskin | 2009-05-08 18:23:21 -0400 (Fri, 08 May 2009) | 13 lines

  Issue 5954, PyFrame_GetLineNumber:
  Most uses of PyCode_Addr2Line
  (http://www.google.com/codesearch?q=PyCode_Addr2Line) are just trying to get
  the line number of a specified frame, but there's no way to do that directly.
  Forcing people to go through the code object makes them know more about the
  guts of the interpreter than they should need.

  The remaining uses of PyCode_Addr2Line seem to be getting the line from a
  traceback (for example,
  http://www.google.com/codesearch/p?hl=en#u_9_nDrchrw/pygame-1.7.1release/src/base.c&q=PyCode_Addr2Line),
  which is replaced by the tb_lineno field.  So we may be able to deprecate
  PyCode_Addr2Line entirely for external use.
........
  r72879 | jeffrey.yasskin | 2009-05-23 19:23:01 -0400 (Sat, 23 May 2009) | 14 lines

  Issue #6042:
  lnotab-based tracing is very complicated and isn't documented very well.  There
  were at least 3 comment blocks purporting to document co_lnotab, and none did a
  very good job. This patch unifies them into Objects/lnotab_notes.txt which
  tries to completely capture the current state of affairs.

  I also discovered that we've attached 2 layers of patches to the basic tracing
  scheme. The first layer avoids jumping to instructions that don't start a line,
  to avoid problems in if statements and while loops.  The second layer
  discovered that jumps backward do need to trace at instructions that don't
  start a line, so it added extra lnotab entries for 'while' and 'for' loops, and
  added a special case for backward jumps within the same line. I replaced these
  patches by just treating forward and backward jumps differently.
........
2009-07-21 04:30:03 +00:00
Benjamin Peterson b1715f131f use stack altering macros here 2009-06-28 16:21:52 +00:00
Benjamin Peterson 6d46a91dc0 Merged revisions 73614-73615 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r73614 | benjamin.peterson | 2009-06-28 11:08:02 -0500 (Sun, 28 Jun 2009) | 1 line

  add two generic macros for peeking and setting in the stack
........
  r73615 | benjamin.peterson | 2009-06-28 11:14:07 -0500 (Sun, 28 Jun 2009) | 1 line

  use stack macros
........
2009-06-28 16:17:34 +00:00
Benjamin Peterson ac8c73075a this is better written as an assertion 2009-06-28 16:03:15 +00:00
Benjamin Peterson fec42da1ab update comments 2009-06-28 15:55:46 +00:00
Benjamin Peterson 176101d660 correctly rearrange the stack in the exception case of WITH_CLEANUP 2009-06-28 15:40:50 +00:00
Benjamin Peterson 876b2f286b Merged revisions 72912,72920,72940 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r72912 | benjamin.peterson | 2009-05-25 08:13:44 -0500 (Mon, 25 May 2009) | 5 lines

  add a SETUP_WITH opcode

  It speeds up the with statement and correctly looks up the special
  methods involved.
........
  r72920 | benjamin.peterson | 2009-05-25 15:12:57 -0500 (Mon, 25 May 2009) | 1 line

  take into account the fact that SETUP_WITH pushes a finally block
........
  r72940 | benjamin.peterson | 2009-05-26 07:49:59 -0500 (Tue, 26 May 2009) | 1 line

  teach the peepholer about SETUP_WITH
........
2009-06-28 03:18:59 +00:00
Antoine Pitrou 8e124f3244 Merged revisions 73064 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r73064 | antoine.pitrou | 2009-05-30 23:27:00 +0200 (sam., 30 mai 2009) | 4 lines

  Issue #5330: C functions called with keyword arguments were not reported by
  the various profiling modules (profile, cProfile). Patch by Hagen Fürstenau.
........
2009-05-30 21:41:10 +00:00
Benjamin Peterson efb06b0d91 Merged revisions 69811,69947 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r69811 | collin.winter | 2009-02-20 13:30:41 -0600 (Fri, 20 Feb 2009) | 2 lines

  Issue 5176: special-case string formatting in BINARY_MODULO implementation. This shows a modest (1-3%) speed-up in templating systems, for example.
........
  r69947 | jeffrey.yasskin | 2009-02-24 16:48:34 -0600 (Tue, 24 Feb 2009) | 3 lines

  Tools/scripts/analyze_dxp.py, a module with some helper functions to
  analyze the output of sys.getdxp().
........
2009-02-26 18:55:48 +00:00
Jeffrey Yasskin 9de7ec7868 http://bugs.python.org/issue4715
This patch by Antoine Pitrou optimizes the bytecode for conditional branches by
merging the following "POP_TOP" instruction into the conditional jump.  For
example, the list comprehension "[x for x in l if not x]" produced the
following bytecode:

  1           0 BUILD_LIST               0
              3 LOAD_FAST                0 (.0)
        >>    6 FOR_ITER                23 (to 32)
              9 STORE_FAST               1 (x)
             12 LOAD_FAST                1 (x)
             15 JUMP_IF_TRUE            10 (to 28)
             18 POP_TOP
             19 LOAD_FAST                1 (x)
             22 LIST_APPEND              2
             25 JUMP_ABSOLUTE            6
        >>   28 POP_TOP
             29 JUMP_ABSOLUTE            6
        >>   32 RETURN_VALUE

but after the patch it produces the following bytecode:

  1           0 BUILD_LIST               0
              3 LOAD_FAST                0 (.0)
        >>    6 FOR_ITER                18 (to 27)
              9 STORE_FAST               1 (x)
             12 LOAD_FAST                1 (x)
             15 POP_JUMP_IF_TRUE         6
             18 LOAD_FAST                1 (x)
             21 LIST_APPEND              2
             24 JUMP_ABSOLUTE            6
        >>   27 RETURN_VALUE

Notice that not only the code is shorter, but the conditional jump
(POP_JUMP_IF_TRUE) jumps right to the start of the loop instead of going through
the JUMP_ABSOLUTE at the end. "continue" statements are helped
similarly.

Furthermore, the old jump opcodes (JUMP_IF_FALSE, JUMP_IF_TRUE) have been
replaced by two new opcodes:
- JUMP_IF_TRUE_OR_POP, which jumps if true and pops otherwise
- JUMP_IF_FALSE_OR_POP, which jumps if false and pops otherwise
2009-02-25 02:25:04 +00:00
Antoine Pitrou b52ec78baf Issue #4753: By enabling a configure option named '--with-computed-gotos'
on compilers that support it (notably: gcc, SunPro, icc), the bytecode
evaluation loop is compiled with a new dispatch mechanism which gives
speedups of up to 20%, depending on the system, on various benchmarks.
2009-01-25 16:34:23 +00:00