Commit Graph

829 Commits

Author SHA1 Message Date
Dennis Sweeney 8a35ce3796
gh-91428: Add _PyOpcode_OpName to opcode.h of debug builds (GH-91430) 2022-04-11 18:33:00 -04:00
Petr Viktorin 1c2fddddae
Add feature macro PY_HAVE_THREAD_NATIVE_ID to the stable ABI definition (GH-32365) 2022-04-08 14:35:11 +02:00
Petr Viktorin d79f118d04
bpo-47115: Document which parts of structs are in limited API/stable ABI (GH-32196)
Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no>
2022-04-06 16:50:45 +02:00
Eric Snow e7bb7c2f04
bpo-47146: Stop Depending On regen-deepfreeze For regen-global-objects (gh-32218)
This effectively reverts the Makefile change in gh-31637. I've added some notes so it is more clear what is going on.

We also update the "Check if generated files are up to date" job to run "make regen-deepfreeze" to ensure "make regen-global-objects" catches deepfreeze.c.

https://bugs.python.org/issue47146
2022-03-31 14:29:52 -06:00
Eric Snow db4dada510
bpo-47146: Avoid Using make Recursively (gh-32206)
https://bugs.python.org/issue47146
2022-03-30 19:24:02 -06:00
Hugo van Kemenade 6881ea936e
bpo-47126: Update to canonical PEP URLs specified by PEP 676 (GH-32124) 2022-03-30 12:00:27 +01:00
Kumar Aditya 785cc67705
bpo-46429: tweak deepfreeze output (#32107) 2022-03-27 11:46:22 -07:00
Eric Snow febf54bcf3
bpo-46712: Do not Regen Deep-Frozen Modules before Generating Global Objects (gh-32061)
We have to run "make regen-deepfreeze" before running Tools/scripts/generate-global-objects.py; otherwise we will miss any changes to global objects in deep-frozen modules (which aren't committed in the repo).  However, building $(PYTHON_FOR_FREEZE) fails if one of its source files had a global object (e.g. via _Py_ID(...)) added or removed, without generate-global-objects.py running first.  So "make regen-global-objects" would sometimes fail.

We solve this by running generate-global-objects.py before *and* after "make regen-deepfreeze". To speed things up and cut down on noise, we also avoid updating the global objects files if there are no changes to them.

https://bugs.python.org/issue46712
2022-03-23 09:55:52 -06:00
Jeremy Kloth 88872a29f1
bpo-47084: Clear Unicode cached representations on finalization (GH-32032) 2022-03-22 13:53:51 +01:00
Brandt Bucher 2bde6827ea
bpo-46841: Quicken code in-place (GH-31888)
* Moves the bytecode to the end of the corresponding PyCodeObject, and quickens it in-place.

* Removes the almost-always-unused co_varnames, co_freevars, and co_cellvars member caches

* _PyOpcode_Deopt is a new mapping from all opcodes to their un-quickened forms.

* _PyOpcode_InlineCacheEntries is renamed to _PyOpcode_Caches

* _Py_IncrementCountAndMaybeQuicken is renamed to _PyCode_Warmup

* _Py_Quicken is renamed to _PyCode_Quicken

* _co_quickened is renamed to _co_code_adaptive (and is now a read-only memoryview).

* Do not emit unused nonzero opargs anymore in the compiler.
2022-03-21 11:11:17 +00:00
Dennis Sweeney d7a93cbf4b
summarize_stats.py: add pairs by opcode (GH-31957) 2022-03-18 10:10:31 +00:00
Hugo van Kemenade 23abae621f
CI: Fix patchcheck (GH-31708) 2022-03-14 15:28:57 +02:00
Kumar Aditya 8714b6fa27
bpo-46881: Statically allocate and initialize the latin1 characters. (GH-31616) 2022-03-09 15:02:00 -08:00
Serhiy Storchaka 6927632492
Remove trailing spaces (GH-31695) 2022-03-05 17:47:00 +02:00
Eric Snow 21099fc064
bpo-46712: Let generate_global_objects.py Run on Earlier Python Versions (gh-31637)
https://bugs.python.org/issue46712
2022-03-01 14:29:54 -07:00
Eric Snow 08deed1af5
bpo-46753: Add the empty tuple to the _PyRuntimeState.global_objects. (gh-31345)
https://bugs.python.org/issue46753
2022-02-28 15:15:48 -07:00
Mark Shannon 4558af5a8f
bpo-46841: Move the cache for `LOAD_GLOBAL` inline. (GH-31575) 2022-02-28 12:56:29 +00:00
Kumar Aditya 0d9b565e62
Propagate errors (however unlikely) from _Py_Deepfreeze_Init() (GH-31596) 2022-02-26 08:35:03 -08:00
Kumar Aditya eb002dbe0d
bpo-46712: Share global string identifiers in deepfreeze (GH-31261)
Where appropriate, deepfreeze.c now uses `&_Py_ID(blah)` references instead of locally defining constants. This saves some space.
2022-02-25 10:05:24 -08:00
Brandt Bucher 0f41aac109
bpo-46841: Use *inline* caching for `BINARY_OP` (GH-31543) 2022-02-25 12:11:34 +00:00
Kumar Aditya 4dc746310b
bpo-46430: Fix memory leak in interned strings of deep-frozen modules (GH-31549) 2022-02-24 17:54:06 +01:00
Mark Shannon 09487c11a5
Fix reporting of specialization stats. (GH-31503) 2022-02-22 17:18:10 +00:00
Mark Shannon 1320d56ff7
Remove pair-counts from specialization stats. (GH-31500) 2022-02-22 15:44:31 +00:00
Eric Snow 4d8a515d19
bpo-46541: Scan Fewer Files in generate_global_objects.py (gh-31364)
https://bugs.python.org/issue46541
2022-02-15 20:07:11 -07:00
Eric Snow 6c89589486
bpo-46541: Drop the check for orphaned global strings. (gh-31363)
https://bugs.python.org/issue46541
2022-02-15 20:06:38 -07:00
Eric Snow 12360aa159
bpo-46541: Discover the global strings. (gh-31346)
Instead of manually enumerating the global strings in generate_global_objects.py, we extrapolate the list from usage of _Py_ID() and _Py_STR() in the source files.

This is partly inspired by gh-31261.

https://bugs.python.org/issue46541
2022-02-14 17:36:51 -07:00
Eric Snow 1d9036425e
Regen the global objects using PYTHON_FOR_REGEN. (gh-31344)
https://bugs.python.org/issue46541
2022-02-14 16:07:09 -07:00
Mark Shannon 0ade875ebe
Add pair counts to stats output and summary. (GH-31324) 2022-02-14 15:53:38 +00:00
Mark Shannon b0662ae5c8
Add stats for PRECALL_FUNCTION. (GH-31250) 2022-02-10 11:47:52 +00:00
Mark Shannon cfc1cecd7b
Right justify numeric columns in stats summary script. (GH-31234) 2022-02-10 11:01:18 +00:00
Kumar Aditya c0a5ebeb12
bpo-46430: Intern strings in deep-frozen modules (GH-30683) 2022-02-09 08:52:42 -08:00
Mark Shannon f71a69aa92
bpo-46072: Output stats as markdown with collapsible sections. (GH-31228) 2022-02-09 12:30:26 +00:00
Eric Snow 81c72044a1
bpo-46541: Replace core use of _Py_IDENTIFIER() with statically initialized global objects. (gh-30928)
We're no longer using _Py_IDENTIFIER() (or _Py_static_string()) in any core CPython code.  It is still used in a number of non-builtin stdlib modules.

The replacement is: PyUnicodeObject (not pointer) fields under _PyRuntimeState, statically initialized as part of _PyRuntime.  A new _Py_GET_GLOBAL_IDENTIFIER() macro facilitates lookup of the fields (along with _Py_GET_GLOBAL_STRING() for non-identifier strings).

https://bugs.python.org/issue46541#msg411799 explains the rationale for this change.

The core of the change is in:

* (new) Include/internal/pycore_global_strings.h - the declarations for the global strings, along with the macros
* Include/internal/pycore_runtime_init.h - added the static initializers for the global strings
* Include/internal/pycore_global_objects.h - where the struct in pycore_global_strings.h is hooked into _PyRuntimeState
* Tools/scripts/generate_global_objects.py - added generation of the global string declarations and static initializers

I've also added a --check flag to generate_global_objects.py (along with make check-global-objects) to check for unused global strings.  That check is added to the PR CI config.

The remainder of this change updates the core code to use _Py_GET_GLOBAL_IDENTIFIER() instead of _Py_IDENTIFIER() and the related _Py*Id functions (likewise for _Py_GET_GLOBAL_STRING() instead of _Py_static_string()).  This includes adding a few functions where there wasn't already an alternative to _Py*Id(), replacing the _Py_Identifier * parameter with PyObject *.

The following are not changed (yet):

* stop using _Py_IDENTIFIER() in the stdlib modules
* (maybe) get rid of _Py_IDENTIFIER(), etc. entirely -- this may not be doable as at least one package on PyPI using this (private) API
* (maybe) intern the strings during runtime init

https://bugs.python.org/issue46541
2022-02-08 13:39:07 -07:00
Mark Shannon 328fe3fd20
Print summary stats for overall success of specialization. (GH-31211) 2022-02-08 11:50:02 +00:00
Kumar Aditya 9d4161a60c
bpo-46608: Fix argument parsing in freeze_modules.py (GH-31131) 2022-02-05 07:59:48 -08:00
Kumar Aditya bf95ff91f2
bpo-46608: exclude marshalled-frozen data if deep-freezing to save 300 KB space (GH-31074)
This reduces the size of the data segment by **300 KB** of the executable because if the modules are deep-frozen then the marshalled frozen data just wastes space. This was inspired by comment by @gvanrossum in https://github.com/python/cpython/pull/29118#issuecomment-958521863. Note: There is a new option `--deepfreeze-only` in `freeze_modules.py` to change this behavior, it is on be default to save disk space.
```console 
# du -s ./python before
27892   ./python
# du -s ./python after
27524   ./python
```

Automerge-Triggered-By: GH:ericsnowcurrently
2022-02-04 09:57:03 -08:00
Mark Shannon 832876b992
Add miss stats for specialized instructions. (GH-31108) 2022-02-04 09:56:46 +00:00
Mark Shannon 0d05da1fbf
Add specialization stats for FOR_ITER. (GH-31079) 2022-02-02 15:56:47 +00:00
Mark Shannon 187930f74c
bpo-46072: Add some frame stats. (GH-31060) 2022-02-02 11:01:33 +00:00
Mark Shannon 48be46ec1f
bpo-46072: Add some object layout and allocation stats (GH-31051) 2022-02-01 15:05:18 +00:00
Mark Shannon 90ab138bbd
bpo-46072: Add simple stats for Python calls. (GH-30989) 2022-01-28 15:20:33 +00:00
Kumar Aditya 5a9e423473
bpo-46449: deepfreeze get_code() now returns strong ref (GH-30987) 2022-01-28 13:41:13 +01:00
Christian Heimes 26b0482393
bpo-46476: Simplify and fix _PyStaticCode_Dealloc (GH-30965) 2022-01-27 19:32:12 +00:00
Eric Snow 247480a21c
bpo-46541: Generate the global objects initializer. (gh-30941)
This change is a prerequisite for generating code for other global objects (like strings in gh-30928).

(We borrowed some code from Tools/scripts/deepfreeze.py.)

https://bugs.python.org/issue46541
2022-01-27 11:06:09 -07:00
Kumar Aditya c7f810b34d
bpo-46476: Fix memory leak in code objects generated by deepfreeze (GH-30853)
Add _Py_Deepfreeze_Fini() and _PyStaticCode_Dealloc() functions.
2022-01-27 14:03:47 +01:00
Kumar Aditya ca78130d7e
bpo-46471: Use single byte singletons (GH-30781) 2022-01-23 09:45:39 -08:00
Kumar Aditya ef3ef6fa43
bpo-46429: Merge all deepfrozen files into one (GH-30572) 2022-01-20 08:38:39 -08:00
Kumar Aditya 194ecc6d44
bpo-46443: deepfreeze: use small ints and singleton zero bytes (GH-30715) 2022-01-19 22:13:21 -08:00
Dennis Sweeney 7537f60087
bpo-45609: More specialization stats for STORE_SUBSCR (GH-30193) 2022-01-04 18:05:09 +00:00
Hugo van Kemenade 2cf7d02b99
bpo-46178: Remove/rename redundant Travis CI code (#30309) 2021-12-30 16:16:27 -08:00
Dong-hee Na 196b53eb1e
bpo-45189: Drop the "list_frozen" command from _test_embed. (GH-30273) 2021-12-28 11:05:50 +09:00
Mark Shannon efd6236d36
bpo-46072: Add top level stats struct (GH-30169) 2021-12-17 14:48:01 +00:00
Mark Shannon 4506bbede1
bpo-46072: Document --enable-stats option. (GH-30139) 2021-12-16 13:40:54 +00:00
Mark Shannon 342b93f9f2
bpo-46072: Add --with-pystats configure option to simplify gathering of VM stats (GH-30116)
* Simplify specialization stats collection macros.

* Add --enable-pystats option to configure.

* Update specialization summary script to handle larger number of kinds
2021-12-15 15:32:32 +00:00
Christian Heimes eb483c46d6
bpo-45949: Pure Python freeze module for cross builds (GH-29899) 2021-12-13 20:48:46 +01:00
Petr Viktorin 98e506ae8a
bpo-43795: Document stable_abi.txt format and contents (GH-29956)
Also mention that removals generally aren't allowed.
2021-12-11 00:34:31 +01:00
Christian Heimes 16638a4bdb
bpo-45654: No need to freeze types (GH-30028) 2021-12-10 19:09:09 +01:00
Kumar Aditya 44b0e76f2a
bpo-45654: Freeze the runpy module and stuff it imports (GH-29903) 2021-12-09 08:51:09 -08:00
Christian Heimes 84ca1232b0
bpo-45950: Introduce Bootstrap Python again (#29859)
The build system now uses a :program:`_bootstrap_python` interpreter for
freezing and deepfreezing again. To speed up build process the build tools
:program:`_bootstrap_python` and :program:`_freeze_module` are no longer
build with LTO.

Cross building depends on a build Python interpreter, which must have same
version and bytecode as target host Python.
2021-12-03 16:01:11 +01:00
Kumar Aditya b0b10e146b
bpo-45019: Cleanup module freezing and deepfreeze (#29772) 2021-11-26 08:50:54 -08:00
Kumar Aditya 256f9c4588
Fix typo in freeze_modules (#29744) 2021-11-24 11:12:03 -08:00
Christian Heimes 5c4b19ec49
bpo-45020: Fix strict-prototypes warning (GH-29755) 2021-11-24 20:01:39 +01:00
Christian Heimes dd8ce9ea8d
bpo-45886: Allow overriding freeze command for cross compiling (GH-29735) 2021-11-24 08:07:15 +01:00
Christian Heimes f840398a5f
bpo-45873: Restore Python 3.6 compatibility (GH-29730)
Co-authored-by: Guido van Rossum <gvanrossum@gmail.com>
2021-11-23 21:36:40 +01:00
Guido van Rossum 5be98e57b3
bpo-45873: Get rid of bootstrap_python (#29717)
Instead we use $(PYTHON_FOR_REGEN) .../deepfreeze.py with the
frozen .h file as input, as we did for Windows in bpo-45850.

We also get rid of the code that generates the .h files
when make regen-frozen is run (i.e., .../make_frozen.py),
and the MANIFEST file.

Restore Python 3.8 and 3.9 as Windows host Python again

Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
2021-11-23 08:56:06 -08:00
Neil Schemenauer 457e6a6e96
bpo-45561: Run smelly.py tool from $(srcdir) (GH-29138) 2021-11-23 08:51:02 +01:00
Guido van Rossum 1037ca5a8e
bpo-45850: Implement deep-freeze on Windows (#29648)
Implement changes to build with deep-frozen modules on Windows.
Note that we now require Python 3.10 as the "bootstrap" or "host" Python.
This causes a modest startup speed (around 7%) on Windows.
2021-11-22 10:09:48 -08:00
Brandt Bucher 9178f533ff
bpo-45636: Merge all numeric operators (GH-29482) 2021-11-10 22:56:22 -08:00
Guido van Rossum 1cbaa505d0
bpo-45696: Deep-freeze selected modules (GH-29118)
This gains 10% or more in startup time for `python -c pass` on UNIX-ish systems.

The Makefile.pre.in generating code builds on Eric's work for bpo-45020, but the .c file generator is new.

Windows version TBD.
2021-11-10 18:01:53 -08:00
Christian Heimes 3409899128
bpo-45688: Add _scproxy to sys.stdlib_module_names (GH-29358) 2021-11-02 12:08:40 +01:00
Eric Snow 074fa57506
bpo-45395: Make custom frozen modules additions instead of replacements. (gh-28778)
Currently custom modules (the array set on PyImport_FrozenModules) replace all the frozen stdlib modules. That can be problematic and is unlikely to be what the user wants. This change treats the custom frozen modules as additions instead. They take precedence over all other frozen modules except for those needed to bootstrap the import system. If the "code" field of an entry in the custom array is NULL then that frozen module is treated as disabled, which allows a custom entry to disable a frozen stdlib module.

This change allows us to get rid of is_essential_frozen_module() and simplifies the logic for which frozen modules should be ignored.

https://bugs.python.org/issue45395
2021-10-28 15:04:33 -06:00
Petr Viktorin 276468dddb
bpo-43795: Add a test for Stable ABI symbol availability using ctypes (GH-26354)
This is a cross-platform check that the symbols are actually
exported in the ABI, not e.g. hidden in a macro.

Caveat: PyModule_Create2 & PyModule_FromDefAndSpec2 are skipped.

These aren't exported on some of our buildbots. This is a bug
(bpo-44133). This test now makes sure all the others don't regress.
2021-10-22 10:12:06 +02:00
Victor Stinner 37b1d607bf
po-35134: Move Include/funcobject.h to Include/cpython/ (GH-28958)
Remove redundant "#ifndef Py_LIMITED_API" in funcobject.h.
2021-10-15 01:50:28 +02:00
Inada Naoki a1c3c9e824
Fix EncodingWarning in test_tools. (GH-28846) 2021-10-10 09:14:40 +02:00
Victor Stinner ff8859d965
bpo-45402: Fix test_tools.test_sundry() (GH-28786)
Fix test_tools.test_sundry() when Python is built out of tree: fix
how the freeze_modules.py tool locates the _freeze_module program.
2021-10-07 21:19:13 +02:00
Christian Clauss 682aecfdeb
Fix typos in the Tools directory (GH-28769)
Like #28744 but for the Tools directory.

[skip issue] Opening a related issue is pending python/psf-infra-meta#130

Automerge-Triggered-By: GH:pablogsal
2021-10-06 10:55:16 -07:00
Eric Snow 08285d563e
bpo-45020: Identify which frozen modules are actually aliases. (gh-28655)
In the list of generated frozen modules at the top of Tools/scripts/freeze_modules.py, you will find that some of the modules have a different name than the module (or .py file) that is actually frozen. Let's call each case an "alias". Aliases do not come into play until we get to the (generated) list of modules in Python/frozen.c. (The tool for freezing modules, Programs/_freeze_module, is only concerned with the source file, not the module it will be used for.)

Knowledge of which frozen modules are aliases (and the identity of the original module) normally isn't important. However, this information is valuable when we go to set __file__ on frozen stdlib modules. This change updates Tools/scripts/freeze_modules.py to map aliases to the original module name (or None if not a stdlib module) in Python/frozen.c. We also add a helper function in Python/import.c to look up a frozen module's alias and add the result of that function to the frozen info returned from find_frozen().

https://bugs.python.org/issue45020
2021-10-05 11:26:37 -06:00
Mark Shannon bd627eb7ed
bpo-43760: Check for tracing using 'bitwise or' instead of branch in dispatch. (GH-28723) 2021-10-05 11:01:11 +01:00
Eric Snow 7e5c107541
bpo-45020: Add more test cases for frozen modules. (gh-28664)
I've added a number of test-only modules. Some of those cases are covered by the recently frozen stdlib modules (and some will be once we add encodings back in). However, I figured we'd play it safe by having a set of modules guaranteed to be there during tests.

https://bugs.python.org/issue45020
2021-09-30 18:38:52 -06:00
Inada Naoki a143717003
Fix EncodingWarning in freeze_modules. (GH-28591) 2021-09-30 12:36:16 +09:00
Eric Snow 45ca1c0413
bpo-45020: Do not freeze <pkg>/__init__.py twice. (gh-28635)
Currently we're freezing the __init__.py twice, duplicating the built data unnecessarily With this change we do it once. There is no change in runtime behavior.

https://bugs.python.org/issue45020
2021-09-29 12:55:35 -06:00
Niyas Sait adc5d32f47
Select correct tool platform when building on Windows ARM64 natively (GH-28491) 2021-09-27 20:52:54 +01:00
Eric Snow 7c801e0fa6
bpo-45020: Fix some corner cases for frozen module generation. (gh-28538)
This also includes some cleanup in preparation for a PR to make the "make all" output less noisy.

https://bugs.python.org/issue45020
2021-09-24 14:35:47 -06:00
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
Victor Stinner 41551ee7e2
bpo-45020: Fix build out of source tree (GH-28410)
* Makefile.pre.in: Add $(srcdir) when needed, remove it when it was
  used by mistake.
* freeze_modules.py tool uses ./Programs/_freeze_module if the
  executable doesn't exist in the source tree.
2021-09-17 20:20:43 +02:00
Victor Stinner c5a677da9e
bpo-45231: update_file.py preserves end of line (GH-28411)
The update_file.py tool now preserves the end of line of the updated
file. Fix the "make regen-frozen" command: it no longer changes the
end of line of PCbuild/ files on Unix. Git changes the end of line
depending on the platform.
2021-09-17 20:12:25 +02: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
Steve Dower 09b4ad11f3
bpo-45188: Windows now regenerates frozen modules at the start of build instead of late (GH-28322)
This will enable us to drop the frozen module header files from the repository.

It does currently cause many source files to be built twice, which just takes more time. For whoever comes to fix this in the future, the files shared between freeze_module and pythoncore should be put into a static library that is consumed by both.
2021-09-15 18:11:12 +01: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
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
Ikko Ashimine 4338aeeb9e
Fix typos in pep384_macrocheck.py (GH-28220)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
2021-09-10 22:44:03 +08: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
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 c83919bd63
Add option to write specialization stats to files and script to summarize. (GH-27575)
* Add option to write stats to random file in a directory.

* Add script to summarize stats.
2021-08-04 11:39:52 +01:00
Petr Viktorin 7cad9cb51b
bpo-43795: Don't list private names in the limited API (GH-26740)
* Remove struct _node from the stable ABI list

This struct was removed along with the old parser in Python 3.9 (PEP 617)

* Stable ABI list: Use the public name "PyFrameObject" rather than "_frame"

* Ensure limited API doesn't contain private names

Names prefixed by an underscore are private by definition.

* Add a blurb
2021-06-16 11:22:36 +02:00
Mark Shannon e117c02837
bpo-44337: Port LOAD_ATTR to PEP 659 adaptive interpreter (GH-26595)
* Specialize LOAD_ATTR with  LOAD_ATTR_SLOT and LOAD_ATTR_SPLIT_KEYS

* Move dict-common.h to internal/pycore_dict.h

* Add LOAD_ATTR_WITH_HINT specialized opcode.

* Quicken in function if loopy

* Specialize LOAD_ATTR for module attributes.

* Add specialization stats
2021-06-10 08:46:01 +01:00
Antoine Pitrou 1aa3530314
bpo-44125: Fix "make patchcheck" on non-English locale (GH-26102)
The patch from [bpo-44074]() does not account for a possibly non-English locale and blindly greps for "HEAD branch" in a possibly localized text.

Automerge-Triggered-By: GH:pitrou
2021-05-13 10:48:15 -07:00
Petr Viktorin b05955d6f5
bpo-43795: PEP 652 user documentation (GH-25668)
- Reformat the C API and ABI Versioning page (and extend/clarify a bit)
- Rewrite the stable ABI docs into a general text on C API Compatibility
- Add a list of Limited API contents, and notes for the individual items. 
- Replace `Include/README.rst` with a link to a devguide page with the same info
2021-05-11 07:04:33 -07:00
Leonardo Lai 21fbbb98ba
bpo-44074: let patchcheck infer the base branch name (GH-25991) 2021-05-10 19:34:27 +01:00
Mark Shannon adcd220556
bpo-40222: "Zero cost" exception handling (GH-25729)
"Zero cost" exception handling.

* Uses a lookup table to determine how to handle exceptions.
* Removes SETUP_FINALLY and POP_TOP block instructions, eliminating (most of) the runtime overhead of try statements.
* Reduces the size of the frame object by about 60%.
2021-05-07 15:19:19 +01:00
Petr Viktorin f6ee4dad58
bpo-43795: Generate python3dll.c and doc data from manifest (PEP 652) (GH-25315) 2021-04-29 11:33:14 +02:00
Inada Naoki 489c36920e
bpo-43651: PEP 597: Fix pdeps used locale encoding (GH-25204) 2021-04-06 17:02:54 +09:00
Victor Stinner 9bb5658bd1
bpo-43688: Support "make regen-limited-abi" in debug mode (GH-25133) 2021-04-02 16:46:08 +02:00
Victor Stinner 61092a99c4
bpo-43690: stable_abi.py no longer parses macros (GH-25136)
The stable_abi.py script no longer parse macros. Macro targets can be
static inline functions which are not part of the stable ABI, only
part of the limited C API.

Run "make regen-limited-abi" to exclude PyType_HasFeature from
Doc/data/stable_abi.dat.
2021-04-01 14:13:42 +02:00
Victor Stinner ad493edf57
bpo-42955: Add _overlapped to sys.stdlib_module_names (GH-25122) 2021-04-01 02:28:23 +02:00
Victor Stinner 28ad12f8fe
bpo-43244: Remove symtable.h header file (GH-24910)
Rename Include/symtable.h to to Include/internal/pycore_symtable.h,
don't export symbols anymore (replace PyAPI_FUNC and PyAPI_DATA with
extern) and rename functions:

* PyST_GetScope() to _PyST_GetScope()
* PySymtable_BuildObject() to _PySymtable_Build()
* PySymtable_Free() to _PySymtable_Free()

Remove PySymtable_Build(), Py_SymtableString() and
Py_SymtableStringObject() functions.

The Py_SymtableString() function was part the stable ABI by mistake
but it could not be used, since the symtable.h header file was
excluded from the limited C API.

The Python symtable module remains available and is unchanged.
2021-03-19 12:41:49 +01:00
Victor Stinner a9c03d7fb7
bpo-43456: Remove _xxsubinterpreters from sys.stdlib_module_names (GH-24814) 2021-03-10 12:10:01 +01:00
Victor Stinner 307745aa42
bpo-43445: Add frozen modules to sys.stdlib_module_names (GH-24798)
Add frozen modules to sys.stdlib_module_names. For example, add
"_frozen_importlib" and "_frozen_importlib_external" names.

Add "list_frozen" command to Programs/_testembed.
2021-03-10 11:14:07 +01:00
Nicholas Sim 4a6bf276ed
bpo-35134: Move non-limited C API files to Include/cpython/ (GH-24561)
Include/{odictobject.h,parser_interface.h,picklebufobject.h,pydebug.h,pyfpe.h}
into Include/cpython/.

Parser: peg_api: include Python.h instead of parser_interface.h.
2021-02-19 15:55:46 +01:00
Nicholas Sim 366dc3a135
bpo-35134: Move Include/{pyarena.h,pyctype.h} to Include/cpython/ (GH-24550)
Move non-limited C API headers pyarena.h and pyctype.h
into Include/cpython/ directory.
2021-02-17 19:30:31 +01:00
Victor Stinner 801bb0b503
bpo-43103: Add configure --without-static-libpython (GH-24418)
Add a new configure --without-static-libpython option to not build
the libpythonMAJOR.MINOR.a static library and not install the
python.o object file.

Fix smelly.py and stable_abi.py tools when libpython3.10.a is
missing.
2021-02-17 11:14:42 +01:00
Victor Stinner 64fc105b2d
bpo-42955: Remove sub-packages from sys.stdlib_module_names (GH-24353) 2021-01-28 00:03:23 +01:00
Victor Stinner 9852cb3811
bpo-42955: Rename module_names to sys.stdlib_module_names (GH-24332)
* Rename _Py_module_names to _Py_stdlib_module_names.
* Rename Python/module_names.h to Python/stdlib_module_names.h.
2021-01-25 23:12:50 +01:00
Victor Stinner db584bdad3
bpo-42955: Add sys.modules_names (GH-24238)
Add sys.module_names, containing the list of the standard library
module names.
2021-01-25 13:24:42 +01:00
Victor Stinner cad8020cb8
bpo-42955: Add Python/module_names.h (GH-24258)
Add a private list of all stdlib modules: _Py_module_names.

* Add Tools/scripts/generate_module_names.py script.
* Makefile: Add "make regen-module-names" command.
* setup.py: Add --list-module-names option.
* GitHub Action and Travis CI also runs "make regen-module-names",
  not ony "make regen-all", to ensure that the module names remains
  up to date.
2021-01-19 23:04:49 +01:00
Pablo Galindo 0911411e0c
Update stable ABI script for MacOS and update list of exported symbols (GH-23783) 2020-12-15 18:16:13 +00:00
Pablo Galindo 79c1849b9e
bpo-42545: Improve the error message in the stable API script (GH-23648) 2020-12-04 23:19:21 +00:00
Pablo Galindo 85f1dedb8d
bpo-42545: Check that all symbols in the limited ABI are exported (GH-23616) 2020-12-04 22:05:58 +00:00
Victor Stinner ac7d0169d2
bpo-42212: smelly.py also checks the dynamic library (GH-23423)
The smelly.py script now also checks the Python dynamic library and
extension modules, not only the Python static library. Make also the
script more verbose: explain what it does.

The GitHub Action job now builds Python with the libpython dynamic
library.
2020-11-24 13:38:08 +01:00
Mark Shannon 582aaf19e8
bpo-41463: Generate information about jumps from 'opcode.py' rather than duplicating it in 'compile.c' (GH-21714)
Generate information about jumps from 'opcode.py' rather than duplicate it in 'compile.c'
2020-08-04 17:30:11 +01:00
Victor Stinner 8182cc2e68
bpo-39573: Use the Py_TYPE() macro (GH-21433)
Replace obj->ob_type with Py_TYPE(obj).
2020-07-10 12:40:38 +02:00
Lysandros Nikolaou 314858e276
bpo-40939: Remove the old parser (Part 2) (GH-21005)
Remove some remaining files and Makefile targets for the old parser
2020-06-20 19:07:25 +01:00
Pablo Galindo 436b648910
bpo-40939: Remove some extra references to PYTHONOLDPARSER (GH-20815)
Automerge-Triggered-By: @pablogsal
2020-06-11 10:08:05 -07:00
Ammar Askar f82807746d
closes bpo-40385: Remove Tools/scripts/checkpyc.py (GH-19709)
This is one of the few files that has intimate knowledge of the pyc file
format. Since it lacks tests it tends to become outdated fairly quickly.
At present it has been broken since the introduction of PEP 552.
2020-04-24 23:33:59 -05:00
Pablo Galindo c5fc156852
bpo-40334: PEP 617 implementation: New PEG parser for CPython (GH-19503)
Co-authored-by: Guido van Rossum <guido@python.org>
Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
2020-04-22 23:29:27 +01:00
Lysandros Nikolaou 9a4b38f66b
bpo-40267: Fix message when last input character produces a SyntaxError (GH-19521)
When there is a SyntaxError after reading the last input character from
the tokenizer and if no newline follows it, the error message used to be
`unexpected EOF while parsing`, which is wrong.
2020-04-15 11:22:10 -07:00
Victor Stinner e7c98f08e2
bpo-40094: Fix which.py script exit code (GH-19286)
It now uses os.waitstatus_to_exitcode() to convert os.system() exit
status into an exit code.
2020-04-02 03:42:47 +02:00
Mark Shannon 9af0e47b17
bpo-39156: Break up COMPARE_OP into four logically distinct opcodes. (GH-17754)
Break up COMPARE_OP into four logically distinct opcodes:
* COMPARE_OP for rich comparisons
* IS_OP for 'is' and 'is not' tests
* CONTAINS_OP for 'in' and 'is not' tests
* JUMP_IF_NOT_EXC_MATCH for checking exceptions in 'try-except' statements.
2020-01-14 10:12:45 +00:00
Ruediger Pluem 2b7dc40b2a bpo-38347: find pathfix for Python scripts whose name contain a '-' (GH-16536)
pathfix.py: Assume all files that end on '.py' are Python scripts when working recursively.
2019-10-11 15:36:50 +02:00
PatrikKopkan 1dc1acbd73 bpo-37064: Add option -a to pathfix.py tool (GH-15717)
Add option -a to Tools/Scripts/pathfix.py script: add flags.
2019-09-25 14:26:28 +02:00
Greg Price fa3a38d81f Mark files as executable that are meant as scripts. (GH-15354)
This is the converse of GH-15353 -- in addition to plenty of
scripts in the tree that are marked with the executable bit
(and so can be directly executed), there are a few that have
a leading `#!` which could let them be executed, but it doesn't
do anything because they don't have the executable bit set.

Here's a command which finds such files and marks them.  The
first line finds files in the tree with a `#!` line *anywhere*;
the next-to-last step checks that the *first* line is actually of
that form.  In between we filter out files that already have the
bit set, and some files that are meant as fragments to be
consumed by one or another kind of preprocessor.

    $ git grep -l '^#!' \
      | grep -vxFf <( \
          git ls-files --stage \
          | perl -lane 'print $F[3] if (!/^100644/)' \
        ) \
      | grep -ve '\.in$' -e '^Doc/includes/' \
      | while read f; do
          head -c2 "$f" | grep -qxF '#!' \
          && chmod a+x "$f"; \
        done
2019-09-09 07:16:33 -07:00
PatrikKopkan 50254ac4c1 bpo-37064: Add option -k to Tools/scripts/pathfix.py (GH-15548)
Add flag -k to pathscript.py script: preserve shebang flags.
2019-09-05 16:54:54 +02:00
Victor Stinner 27eeaf0f2c
bpo-37704: Remove Tools/scripts/h2py.py (GH-15000)
Use cffi to access a C API in Python.
2019-07-30 17:45:09 +02:00
Zackery Spytz c4e78b116f bpo-14546: Fix the argument handling in Tools/scripts/lll.py (GH-13026) 2019-05-02 18:03:43 +03:00
Stéphane Wirtel 2b7f93b99a
bpo-36345: Update wsgiref example (GH-12562)
Use literalinclude markup to include Tools/scripts/serve.py code.
Tools/scripts/serve.py first argument on the command line is now optional.
2019-04-16 14:52:54 +02:00
Serhiy Storchaka 172bb39452
bpo-22831: Use "with" to avoid possible fd leaks in tools (part 2). (GH-10927) 2019-03-30 08:33:02 +02:00
Serhiy Storchaka afbb7a371f
bpo-22831: Use "with" to avoid possible fd leaks in tools (part 1). (GH-10926) 2019-03-30 08:32:18 +02:00
Stefan Behnel 68d228f174 bpo-35884: Add string-keys-only microbenchmark for dict access to var_access_benchmark.py (GH-11905) 2019-03-25 01:20:53 -07:00
Raymond Hettinger 43766f82dd bpo-35884: Add missing FIFO queue benchmark (GH-11898)
https://bugs.python.org/issue35884
2019-02-16 12:51:02 -08:00
Raymond Hettinger 9da3583e78 Fix typo (micro->nano) (GH-11759) 2019-02-04 23:32:55 -08:00
Raymond Hettinger f75d59e1a8
bpo-35884: Add variable access benchmarking script (GH-11725) 2019-02-02 22:54:56 -08:00
Serhiy Storchaka 8ac658114d
bpo-30455: Generate all token related code and docs from Grammar/Tokens. (GH-10370)
"Include/token.h", "Lib/token.py" (containing now some data moved from
"Lib/tokenize.py") and new files "Parser/token.c" (containing the code
moved from "Parser/tokenizer.c") and "Doc/library/token-list.inc" (included
in "Doc/library/token.rst") are now generated from "Grammar/Tokens" by
"Tools/scripts/generate_token.py". The script overwrites files only if
needed and can be used on the read-only sources tree.

"Lib/symbol.py" is now generated by "Tools/scripts/generate_symbol_py.py"
instead of been executable itself.

Added new make targets "regen-token" and "regen-symbol" which are now
dependencies of "regen-all".

The documentation contains now strings for operators and punctuation tokens.
2018-12-22 11:18:40 +02:00
Serhiy Storchaka 34fd4c2019
bpo-35133: Fix mistakes when concatenate string literals on different lines. (GH-10284)
Two kind of mistakes:

1. Missed space. After concatenating there is no space between words.

2. Missed comma. Causes unintentional concatenating in a list of strings.
2018-11-05 16:20:25 +02:00
Alexey Izbyshev aa95bfb5fe bpo-32256: Make patchcheck.py work for out-of-tree builds (GH-4760)
Set SRCDIR as the current directory for git.
2018-10-20 02:49:41 +02:00
Shivank98 e3d1455fe4 Update opcode.h header comment to mention the source data file (GH-9935)
This is intended to help code explorers find out more about what's defined there.
2018-10-18 14:53:18 -05:00
Ned Deily 9d6d06e806
pypi.python.org -> pypi.org (GH-7613) 2018-06-11 00:45:50 -04:00