summaryrefslogtreecommitdiffstats
path: root/Python
Commit message (Collapse)AuthorAgeFilesLines
* bpo-43693: Un-revert commits 2c1e258 and b2bf2bc. (gh-26577)Eric Snow2021-06-078-5409/+5397
| | | | | | | | | | These were reverted in gh-26530 (commit 17c4edc) due to refleaks. * 2c1e258 - Compute deref offsets in compiler (gh-25152) * b2bf2bc - Add new internal code objects fields: co_fastlocalnames and co_fastlocalkinds. (gh-26388) This change fixes the refleaks. https://bugs.python.org/issue43693
* bpo-44187: Quickening infrastructure (GH-26264)Mark Shannon2021-06-074-7/+261
| | | | | | | | | | | | | | * Add co_firstinstr field to code object. * Implement barebones quickening. * Use non-quickened bytecode when tracing. * Add NEWS item * Add new file to Windows build. * Don't specialize instructions with EXTENDED_ARG.
* bpo-43693: Revert commits 2c1e2583fdc4db6b43d163239ea42b0e8394171f and ↵Pablo Galindo2021-06-048-5395/+5409
| | | | | | | | | | | | | b2bf2bc1ece673d387341e06c8d3c2bc6e259747 (GH-26530) * Revert "bpo-43693: Compute deref offsets in compiler (gh-25152)" This reverts commit b2bf2bc1ece673d387341e06c8d3c2bc6e259747. * Revert "bpo-43693: Add new internal code objects fields: co_fastlocalnames and co_fastlocalkinds. (gh-26388)" This reverts commit 2c1e2583fdc4db6b43d163239ea42b0e8394171f. These two commits are breaking the refleak buildbots.
* bpo-43693: Compute deref offsets in compiler (gh-25152)Mark Shannon2021-06-044-155/+164
| | | | | | Merges locals and cells into a single array. Saves a pointer in the interpreter and means that we don't need the LOAD_CLOSURE opcode any more https://bugs.python.org/issue43693
* bpo-32280: Store _PyRuntime in a named section (GH-4802)Max Bélanger2021-06-031-2/+28
| | | | | This commit stores the _PyRuntime structure in a section of the same name. This allows a debugging or crash reporting tool to quickly locate this structure at runtime without requiring the symbol table. Co-authored-by: Pablo Galindo <pablogsal@gmail.com>
* bpo-11105: Do not crash when compiling recursive ASTs (GH-20594)Batuhan Taskaya2021-06-031-0/+808
| | | | | | | When compiling an AST object with a direct / indirect reference cycles, on the conversion phase because of exceeding amount of calls, a segfault was raised. This patch adds recursion guards to places for preventing user inputs to not to crash AST but instead raise a RecursionError.
* bpo-43693: Add new internal code objects fields: co_fastlocalnames and ↵Eric Snow2021-06-038-5389/+5366
| | | | | | | | | | | | | | | | | co_fastlocalkinds. (gh-26388) A number of places in the code base (notably ceval.c and frameobject.c) rely on mapping variable names to indices in the frame "locals plus" array (AKA fast locals), and thus opargs. Currently the compiler indirectly encodes that information on the code object as the tuples co_varnames, co_cellvars, and co_freevars. At runtime the dependent code must calculate the proper mapping from those, which isn't ideal and impacts performance-sensitive sections. This is something we can easily address in the compiler instead. This change addresses the situation by replacing internal use of co_varnames, etc. with a single combined tuple of names in locals-plus order, along with a minimal array mapping each to its kind (local vs. cell vs. free). These two new PyCodeObject fields, co_fastlocalnames and co_fastllocalkinds, are not exposed to Python code for now, but co_varnames, etc. are still available with the same values as before (though computed lazily). Aside from the (mild) performance impact, there are a number of other benefits: * there's now a clear, direct relationship between locals-plus and variables * code that relies on the locals-plus-to-name mapping is simpler * marshaled code objects are smaller and serialize/de-serialize faster Also note that we can take this approach further by expanding the possible values in co_fastlocalkinds to include specific argument types (e.g. positional-only, kwargs). Doing so would allow further speed-ups in _PyEval_MakeFrameVector(), which is where args get unpacked into the locals-plus array. It would also allow us to shrink marshaled code objects even further. https://bugs.python.org/issue43693
* bpo-44298: Fix line numbers for early exits in with statements. (GH-26513)Mark Shannon2021-06-033-2971/+2981
|
* bpo-17792: more accurate error message for unbound variable access ↵Irit Katriel2021-06-021-3/+3
| | | | exceptions (GH-24976)
* bpo-43693: Add _PyCode_New(). (gh-26375)Eric Snow2021-05-276-4435/+4415
| | | | | This is an internal-only API that helps us manage the many values used to create a code object. https://bugs.python.org/issue43693
* bpo-43693: Clean up the PyCodeObject fields. (GH-26364)Eric Snow2021-05-261-9/+8
| | | | | | | | | | * Move up the comment about fields using in hashing/comparision. * Group the fields more clearly. * Add co_ncellvars and co_nfreevars. * Raise ValueError if nlocals != len(varnames), rather than aborting.
* bpo-43879: Add native_thread_id field to PyThreadState (GH-25458)Gabriele N. Tornetta2021-05-261-0/+5
|
* bpo-44156: Make cached string constants in compile.c subinterpreter ↵Ken Jin2021-05-251-52/+44
| | | | compatible (GH-26161)
* bpo-44032: Delay deletion of stack chunks until thread state is deleted. ↵Mark Shannon2021-05-241-7/+7
| | | | (GH-26285)
* bpo-28307: Tests and fixes for optimization of C-style formatting (GH-26318)Serhiy Storchaka2021-05-231-8/+19
| | | | | | Fix errors: * "%10.s" should be equal to "%10.0s", not "%10s". * Tuples with starred expressions caused a SyntaxError.
* bpo-44032: Move data stack to thread from FrameObject. (GH-26076)Mark Shannon2021-05-214-86/+206
| | | | | | | | | | | | | | | | * Remove 'zombie' frames. We won't need them once we are allocating fixed-size frames. * Add co_nlocalplus field to code object to avoid recomputing size of locals + frees + cells. * Move locals, cells and freevars out of frame object into separate memory buffer. * Use per-threadstate allocated memory chunks for local variables. * Move globals and builtins from frame object to per-thread stack. * Move (slow) locals frame object to per-thread stack. * Move internal frame functions to internal header.
* bpo-44131: Py_FrozenMain() uses PyConfig_SetBytesArgv() (GH-26201)Victor Stinner2021-05-201-70/+14
| | | | | Moreover, Py_FrozenMain() relies on Py_InitializeFromConfig() to handle the PYTHONUNBUFFERED environment variable and configure C stdio streams like stdout (make the stream unbuffered).
* Remove unused function in ceval.c (GH-26246)Pablo Galindo2021-05-191-9/+0
|
* bpo-44131: Test Py_FrozenMain() (GH-26126)Victor Stinner2021-05-171-10/+16
| | | | | | | | | * Add test_frozenmain to test_embed * Add Programs/test_frozenmain.py * Add Programs/freeze_test_frozenmain.py * Add Programs/test_frozenmain.h * Add make regen-test-frozenmain * Add test_frozenmain command to Programs/_testembed * _testembed.c: add error(msg) function
* bpo-26110: Add ``CALL_METHOD_KW`` opcode to speedup method calls with ↵Ken Jin2021-05-156-179/+240
| | | | | | | | | keywords (GH-26014) * Add CALL_METHOD_KW * Make CALL_METHOD branchless too since it shares the same code * Place parentheses in STACK_SHRINK
* bpo-28146: Fix a confusing error message in str.format() (GH-24213)Irit Katriel2021-05-131-2/+8
| | | Automerge-Triggered-By: GH:pitrou
* bpo-44094: Remove deprecated PyErr_ APIs. (GH-26011)Inada Naoki2021-05-131-36/+0
| | | These APIs are deprecated since Python 3.3. They are not documented too.
* bpo-44113: Update fromzenmain not to use Py_SetProgramName (GH-26085)Dong-hee Na2021-05-131-2/+8
|
* bpo-44113: Fix compiler warning in PySys_AddWarnOption() (GH-26084)Victor Stinner2021-05-131-0/+3
| | | Ignore Py_DEPRECATED() warning on purpose.
* Remove PyTryblock struct (GH-26059)Mark Shannon2021-05-121-26/+17
|
* bpo-43933: Force RETURN_VALUE bytecodes to have line numbers (GH-26054)Mark Shannon2021-05-123-2939/+2969
|
* Prevent access outside buffer (GH-26012)Dennis Sweeney2021-05-101-3/+5
|
* bpo-28307: Convert simple C-style formatting with literal format into ↵Serhiy Storchaka2021-05-082-2164/+2383
| | | | | | | | | | | f-string. (GH-5012) C-style formatting with literal format containing only format codes %s, %r and %a (with optional width, precision and alignment) will be converted to an equivalent f-string expression. It can speed up formatting more than 2 times by eliminating runtime parsing of the format string and creating temporary tuple.
* bpo-44063: set the missing end locations on the compiler (GH-25956)Batuhan Taskaya2021-05-071-5/+13
|
* bpo-40222: "Zero cost" exception handling (GH-25729)Mark Shannon2021-05-078-5291/+5951
| | | | | | | | "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%.
* bpo-40943: Fix skipitem() didn't raise SystemError (GH-25937)Inada Naoki2021-05-071-8/+5
| | | | `convertitem()` raises `SystemError` when '#' is used without `PY_SSIZE_T_CLEAN`. This commit makes `skipitem()` raise it too.
* bpo-38530: Refactor and improve AttributeError suggestions (GH-25776)Dennis Sweeney2021-05-031-59/+130
| | | | | | | | | | | | | | | | | | | | - Make case-swaps half the cost of any other edit - Refactor Levenshtein code to not use memory allocator, and to bail early on no match. - Add comments to Levenshtein distance code - Add test cases for Levenshtein distance behind a debug macro - Set threshold to `(name_size + item_size + 3) * MOVE_COST / 6`. - Reasoning: similar to `difflib.SequenceMatcher.ratio()` >= 2/3: ``` "Multiset Jaccard similarity" >= 2/3 matching letters / total letters >= 2/3 (name_size - distance + item_size - distance) / (name_size + item_size) >= 2/3 1 - (2*distance) / (name_size + item_size) >= 2/3 1/3 >= (2*distance) / (name_size + item_size) (name_size + item_size) / 6 >= distance With rounding: (name_size + item_size + 3) // 6 >= distance ``` Co-authored-by: Pablo Galindo <pablogsal@gmail.com>
* bpo-43754: Fix compiler warning in Python/compile.c (GH-25855)Pablo Galindo2021-05-031-1/+1
| | | | | This fixes the following warning: 'initializing': conversion from 'Py_ssize_t' to 'int', possible loss of data [D:\a\cpython\cpython\PCbuild\pythoncore.vcxproj]
* bpo-43916: Move the _PyStructSequence_InitType function to the internal API ↵Pablo Galindo2021-05-031-0/+1
| | | | (GH-25854)
* bpo-42725: Render annotations effectless on symbol table with PEP 563 (GH-25583)Batuhan Taskaya2021-05-031-10/+91
|
* bpo-43754: Eliminate bindings for partial pattern matches (GH-25229)Brandt Bucher2021-05-024-340/+483
|
* bpo-43933: Set frame.f_lineno during call to __exit__ (GH-25719)Mark Shannon2021-04-304-2950/+2956
| | | * Set line number of __exit__ call in a with statement to be that of the with keyword.
* bpo-43667: Fix broken Unicode encoding in non-UTF locales on Solaris (GH-25096)Jakub Kulík2021-04-301-0/+106
|
* bpo-43916: PyStdPrinter_Type uses Py_TPFLAGS_DISALLOW_INSTANTIATION (GH-25749)Victor Stinner2021-04-301-1/+1
| | | | | | | The PyStdPrinter_Type type now uses the Py_TPFLAGS_DISALLOW_INSTANTIATION flag to disallow instantiation, rather than seting a tp_init method which always fail. Write also unit tests for PyStdPrinter_Type.
* bpo-43916: Add Py_TPFLAGS_DISALLOW_INSTANTIATION type flag (GH-25721)Victor Stinner2021-04-301-30/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a new Py_TPFLAGS_DISALLOW_INSTANTIATION type flag to disallow creating type instances: set tp_new to NULL and don't create the "__new__" key in the type dictionary. The flag is set automatically on static types if tp_base is NULL or &PyBaseObject_Type and tp_new is NULL. Use the flag on the following types: * _curses.ncurses_version type * _curses_panel.panel * _tkinter.Tcl_Obj * _tkinter.tkapp * _tkinter.tktimertoken * _xxsubinterpretersmodule.ChannelID * sys.flags type * sys.getwindowsversion() type * sys.version_info type Update MyStr example in the C API documentation to use Py_TPFLAGS_DISALLOW_INSTANTIATION. Add _PyStructSequence_InitType() function to create a structseq type with the Py_TPFLAGS_DISALLOW_INSTANTIATION flag set. type_new() calls _PyType_CheckConsistency() at exit.
* bpo-43977: Use tp_flags for collection matching (GH-25723)Mark Shannon2021-04-302-66/+8
| | | | | | | | | | | | | * Add Py_TPFLAGS_SEQUENCE and Py_TPFLAGS_MAPPING, add to all relevant standard builtin classes. * Set relevant flags on collections.abc.Sequence and Mapping. * Use flags in MATCH_SEQUENCE and MATCH_MAPPING opcodes. * Inherit Py_TPFLAGS_SEQUENCE and Py_TPFLAGS_MAPPING. * Add NEWS * Remove interpreter-state map_abc and seq_abc fields.
* bpo-43892: Validate the first term of complex literal value patterns (GH-25735)Brandt Bucher2021-04-302-38/+20
|
* bpo-42800: Rename AUDIT_READ to PY_AUDIT_READ (GH-25736)Steve Dower2021-04-301-1/+1
|
* bpo-42800: add audit hooks for f_code and tb_frame (GH-24182)Ryan Hileman2021-04-291-1/+1
| | | | | | | | | | Accessing the following attributes will now fire PEP 578 style audit hooks as ("object.__getattr__", obj, name): * PyTracebackObject: tb_frame * PyFrameObject: f_code * PyGenObject: gi_code, gi_frame * PyCoroObject: cr_code, cr_frame * PyAsyncGenObject: ag_code, ag_frame Add an AUDIT_READ attribute flag aliased to READ_RESTRICTED. Update obsolete flag documentation.
* bpo-42739: Don't use sentinels to mark end of line table. (GH-25657)Mark Shannon2021-04-295-4952/+4921
| | | | | * Add length parameter to PyLineTable_InitAddressRange and doen't use sentinel values at end of table. Makes the line number table more robust. * Update PyCodeAddressRange to match PEP 626.
* bpo-43892: Make match patterns explicit in the AST (GH-25585)Nick Coghlan2021-04-297-488/+1498
| | | Co-authored-by: Brandt Bucher <brandtbucher@gmail.com>
* bpo-43962: Fix _PyInterpreterState_IDIncref() (GH-25683)Victor Stinner2021-04-281-6/+7
| | | | _PyInterpreterState_IDIncref() now calls _PyInterpreterState_IDInitref() and always increments id_refcount.
* bpo-38530: Require 50% similarity in NameError and AttributeError ↵Dennis Sweeney2021-04-271-1/+4
| | | | suggestions (GH-25584)
* bpo-42609: Check recursion depth in the AST validator and optimizer (GH-23744)Serhiy Storchaka2021-04-252-142/+291
|
* bpo-42737: annotations with complex targets no longer causes any runtime ↵Batuhan Taskaya2021-04-251-0/+6
| | | | effects (GH-23952)