Commit Graph

7059 Commits

Author SHA1 Message Date
Eric Snow 090591636c
bpo-45020: Freeze os, site, and codecs. (gh-28398)
https://bugs.python.org/issue45020
2021-09-17 16:31:31 -06:00
Mark Shannon 064464fc38
bpo-45219: Factor dictkey indexing (GH-28389) 2021-09-17 12:20:51 +01:00
Ken Jin 70bed6f993
bpo-45107: Make LOAD_METHOD_CLASS safer and faster, clean up comments (GH-28177)
* Improve comments

* Check cls is a type, remove dict calculation
2021-09-17 18:47:36 +08:00
Ken Jin 4857e53890
bpo-45203: fix compiler warnings (GH-28357)
Co-authored-by: Mark Shannon <mark@hotpy.org>
2021-09-17 17:48:44 +08:00
Eric Snow fdc6b3d931
bpo-45020: Drop the frozen .h files from the repo. (gh-28392)
The main advantage is that the files will no longer show up in diffs and PRs. That means, for a PR, the number of files / lines changed will more clearly reflect the actual change.  (This is essentially an un-revert of gh-28375.)

https://bugs.python.org/issue45020
2021-09-16 14:20:52 -06:00
Eric Snow 9fd87a5fe5
bpo-45020: Revert "Drop the frozen .h files from the repo." (gh-28380)
gh-28375 broke one of the buildbots. Until I figure out why, I'm rolling the change back.

https://bugs.python.org/issue45020
2021-09-15 23:27:38 -06:00
Eric Snow a9757bf34d
bpo-45020: Drop the frozen .h files from the repo. (gh-28375)
The main advantage is that the files will no longer show up in diffs and PRs. That means, for a PR, the number of files / lines changed will more clearly reflect the actual change.

https://bugs.python.org/issue45020
2021-09-15 19:15:26 -06:00
Eric Snow 3814e2036d
bpo-45019: Clean up the frozen __hello__ module. (gh-28374)
Here's one more small cleanup that should have been in PR gh-28319. We eliminate stdout side-effects from importing the frozen __hello__ module, and update tests accordingly. We also move the module's source file into Lib/ from Toos/freeze/flag.py.

https://bugs.python.org/issue45019
2021-09-15 14:15:32 -06:00
Eric Snow cbeb819710
bpo-45020: Freeze some of the modules imported during startup. (gh-28335)
Doing this provides significant performance gains for runtime startup (~15% with all the imported modules frozen). We don't yet freeze all the imported modules because there are a few hiccups in the build systems we need to sort out first. (See bpo-45186 and bpo-45188.)

Note that in PR GH-28320 we added a command-line flag (-X frozen_modules=[on|off]) that allows users to opt out of (or into) using frozen modules. The default is still "off" but we will change it to "on" as soon as we can do it in a way that does not cause contributors pain.

https://bugs.python.org/issue45020
2021-09-15 10:19:30 -06:00
Mark Shannon 11cdf2a670
bpo-45203: Cleanup stats gathering code for LOAD_METHOD (GH-28352) 2021-09-15 14:55:49 +01:00
Victor Stinner b49263b698
bpo-21302: Add _PyTime_AsNanoseconds() (GH-28350)
Refactor pytime.c:

* Add pytime_from_nanoseconds() and pytime_as_nanoseconds(),
  and use explicitly these functions
* Add two empty lines between functions
* PEP 7: add braces { ... }
* C99: declare variables where they are set
* Rename private functions to lowercase
* Rename error_time_t_overflow() to pytime_time_t_overflow()
* Rename win_perf_counter_frequency() to py_win_perf_counter_frequency()
* py_get_monotonic_clock(): add an assertion to detect overflow when
  mach_absolute_time() unsigned uint64_t is casted to _PyTime_t
  (signed int64_t).

_testcapi: use _PyTime_FromNanoseconds().
2021-09-15 14:26:43 +02:00
Eric Snow a65c86889e
bpo-45020: Add -X frozen_modules=[on|off] to explicitly control use of frozen modules. (gh-28320)
Currently we freeze several modules into the runtime. For each of these modules it is essential to bootstrapping the runtime that they be frozen. Any other stdlib module that we later freeze into the runtime is not essential. We can just as well import from the .py file.  This PR lets users explicitly choose which should be used, with the new "-X frozen_modules=[on|off]" CLI flag. The default is "off" for now.

https://bugs.python.org/issue45020
2021-09-14 17:31:45 -06:00
Irit Katriel c2f1e95337
bpo-45152: Add HAS_CONST macro and get_const_value() function and use… (#28262) 2021-09-14 09:53:32 +01:00
Eric Snow a2d8c4b81b
bpo-45019: Do some cleanup related to frozen modules. (gh-28319)
There are a few things I missed in gh-27980. This is a follow-up that will make subsequent PRs cleaner. It includes fixes to tests and tools that reference the frozen modules.

https://bugs.python.org/issue45019
2021-09-13 16:18:37 -06:00
Serhiy Storchaka 92bf8691fb
bpo-43413: Fix handling keyword arguments in subclasses of some buitin classes (GH-26456)
* Constructors of subclasses of some buitin classes (e.g. tuple, list,
  frozenset) no longer accept arbitrary keyword arguments.
* Subclass of set can now define a __new__() method with additional
  keyword parameters without overriding also __init__().
2021-09-12 13:27:50 +03:00
Vincent Michel 06148b1870
bpo-44219: Release the GIL during isatty syscalls (GH-28250)
Release the GIL while performing isatty() system calls on arbitrary
file descriptors. In particular, this affects os.isatty(),
os.device_encoding() and io.TextIOWrapper. By extension,
io.open() in text mode is also affected.
2021-09-09 15:12:03 +02:00
Florin Spătar 2396fa6537
bpo-44959: Add fallback to extension modules with '.sl' suffix on HP-UX (GH-27857) 2021-09-08 14:43:00 +02:00
Yury Selivanov 2c3474a637
bpo-45123: PyAiter_Check and PyObject_GetAiter fix & rename. (GH-28194)
Fix PyAiter_Check to only check for the `__anext__` presense (not for
`__aiter__`). Rename `PyAiter_Check()` to `PyAIter_Check()`,
`PyObject_GetAiter()` -> `PyObject_GetAIter()`.

Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
2021-09-07 11:52:30 +01:00
Irit Katriel 9e31b3952f
bpo-41031: Match C and Python code formatting of unprintable exceptions and exceptions in the __main__ module. (GH-28139) 2021-09-05 18:54:13 +03:00
Victor Stinner 7974c30b9f
bpo-45094: Add Py_NO_INLINE macro (GH-28140)
* Rename _Py_NO_INLINE macro to Py_NO_INLINE: make it public and
  document it.
* Sort macros in the C API documentation.
2021-09-03 16:44:02 +02:00
Łukasz Langa be9de8721d
bpo-34602: Quadruple stack size on macOS when compiling with UBSAN (GH-27309) 2021-09-03 09:32:19 +02:00
Irit Katriel b4b6342848
bpo-45083: Include the exception class qualname when formatting an exception (GH-28119)
Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no>
2021-09-03 09:30:17 +02:00
Inada Naoki 55c4a92fc1
bpo-45056: Remove trailing unused constants from co_consts (GH-28109) 2021-09-02 13:02:06 +02:00
Victor Stinner a806608705
bpo-45085: Remove the binhex module (GH-28117)
The binhex module, deprecated in Python 3.9, is now removed. The
following binascii functions, deprecated in Python 3.9, are now also
removed:

* a2b_hqx(), b2a_hqx();
* rlecode_hqx(), rledecode_hqx().

The binascii.crc_hqx() function remains available.
2021-09-02 12:10:08 +02:00
Irit Katriel 70ccee418d
bpo-45039: Consistently use ADDOP_LOAD_CONST in compiler rather than ADDOP_O(c, LOAD_CONST,...) (GH-28015) 2021-08-31 20:41:20 +03:00
Brandt Bucher 51999c960e
bpo-37596: Clean up the set/frozenset marshalling code (GH-28068) 2021-08-31 09:18:33 -07:00
Victor Stinner 888d4cc06b
bpo-45061: Enhance faulthandler traceback wit no Python frame (GH-28090)
Fix indentation of <no Python frame> message in a faulthandler
traceback or a Fatal Python error traceback. Example:

Current thread 0x00007f03896fb740 (most recent call first):
  Garbage-collecting
  <no Python frame>
2021-08-31 17:34:29 +02:00
Eric Snow 044e8d866f
bpo-45019: Add a tool to generate list of modules to include for frozen modules (gh-27980)
Frozen modules must be added to several files in order to work properly. Before this change this had to be done manually. Here we add a tool to generate the relevant lines in those files instead. This helps us avoid mistakes and omissions.

https://bugs.python.org/issue45019
2021-08-30 17:25:11 -06:00
Dong-hee Na e6497fe698
bpo-45045: Optimize mapping patterns of structural pattern matching (GH-28043) 2021-08-30 19:02:32 +09:00
Mark Shannon ee9c0527ae
Refine specialization stats (GH-27992) 2021-08-27 12:01:22 +01:00
Mark Shannon d3eaf0cc5b
bpo-44945: Specialize BINARY_ADD (GH-27967) 2021-08-27 09:21:01 +01:00
Dong-hee Na 551da597a0
bpo-45000: Raise SyntaxError when try to delete __debug__ (GH-27947)
Automerge-Triggered-By: GH:pablogsal
2021-08-25 10:54:20 -07:00
Mark Shannon f9242d50b1
bpo-44990: Change layout of evaluation frames. "Layout B" (GH-27933)
Places the locals between the specials and stack. This is the more "natural" layout for a C struct, makes the code simpler and gives a slight speedup (~1%)
2021-08-25 13:44:20 +01:00
Pablo Galindo Salgado 214c2e5d91
Format the Python-tokenize module and fix exit path (GH-27935) 2021-08-25 14:41:14 +02:00
Brandt Bucher 33d95c6fac
bpo-37596: Make `set` and `frozenset` marshalling deterministic (GH-27926) 2021-08-25 13:14:34 +02:00
Pablo Galindo Salgado a24676bedc
Add tests for the C tokenizer and expose it as a private module (GH-27924) 2021-08-24 17:50:05 +01:00
Dong-hee Na c2c857b40f
bpo-44895: Introduce PYTHONDUMPREFSFILE variable for refcount dumping (GH-27767) 2021-08-18 00:52:50 +09:00
Ken Jin 96346cb6d0
bpo-44889: Specialize LOAD_METHOD with PEP 659 adaptive interpreter (GH-27722)
Adds four new instructions:

* LOAD_METHOD_ADAPTIVE
* LOAD_METHOD_CACHED
* LOAD_METHOD_MODULE
* LOAD_METHOD_CLASS
2021-08-17 15:55:55 +01:00
Mark Shannon 4f51fa9e2d
bpo-44900: Add five superinstructions. (GH-27741)
* LOAD_FAST LOAD_FAST
* STORE_FAST LOAD_FAST
* LOAD_FAST LOAD_CONST
* LOAD_CONST LOAD_FAST
* STORE_FAST STORE_FAST
2021-08-16 12:23:13 +01:00
Germán Méndez Bravo 03648a2a91
bpo-43392: Optimize repeated calls to `__import__()` (GH-24735)
Implements a two steps check in `importlib._bootstrap._find_and_load()` to avoid locking when the module has been already imported and it's ready.

---

Using `importlib.__import__()`, after this, does show a big difference:

Before:
```
$ ./python -c 'import timeit; print(timeit.timeit("__import__(\"timeit\")", setup="from importlib import __import__"))'
15.92248619502061
```

After:
```
$ ./python -c 'import timeit; print(timeit.timeit("__import__(\"timeit\")", setup="from importlib import __import__"))'
1.206068897008663
```

---
2021-08-12 11:23:29 -07:00
Pablo Galindo Salgado 8e832fb2a2
bpo-44885: Correct the ast locations of f-strings with format specs and repeated expressions (GH-27729) 2021-08-12 17:13:30 +01:00
Irit Katriel 8ac0886091
bpo-44890: collect specialization stats if Py_DEBUG (GH-27731) 2021-08-12 12:15:06 +01:00
Mark Shannon a530a9538f
bpo-44878: Remove loop from interpreter. All dispatching is done by gotos. (GH-27727) 2021-08-12 11:47:38 +01:00
Irit Katriel 64a7812c17
Update test__opcode and _Py_GetSpecializationStats with recent specialization stat changes (GH-27728) 2021-08-11 17:34:01 +01:00
Mark Shannon f66d00fdd7
bpo-44878: Remove the switch from the main interpreter loop when using computed gotos. (GH-27726)
* Refactor dispatch logic to make flow of control clearer. Moves lltrace and dxprofile instrumentation into DISPATCH macro.

* Remove switch in interpreter loop when using computed gotos. There is no need for two nearly-duplicate dispatch tables.
2021-08-11 14:02:11 +01:00
Mark Shannon 3f3d5dcac3
bpo-44878: _PyEval_EvalFrameDefault readability improvements (GH-27725)
* Move a few variable declarations to point of definition.

* Factor out tracing of function entry into helper function.
2021-08-11 11:47:52 +01:00
Mark Shannon c174eafc33
Add missing DISPATCH() (GH-27715) 2021-08-11 09:25:26 +01:00
Mark Shannon 9816777861
Classify specialization failures. Provides more useful stats, with lower overhead. (GH-27701) 2021-08-10 14:53:05 +01:00
Mark Shannon c7ea1e3dce
Fix stats for STORE_ATTR specialization. (GH-27708) 2021-08-10 11:40:37 +01:00
Irit Katriel d5c217475c
bpo-25782: avoid hang in PyErr_SetObject when current exception has a cycle in its context chain (GH-27626)
Co-authored-by: Dennis Sweeney 36520290+sweeneyde@users.noreply.github.com
2021-08-10 11:37:25 +02:00