cpython/Doc/whatsnew
Batuhan Taskaya d065edfb66
gh-60191: Implement ast.compare (#19211)
* bpo-15987: Implement ast.compare

Add a compare() function that compares two ASTs for structural equality. There are two set of attributes on AST node objects, fields and attributes. The fields are always compared, since they represent the actual structure of the code. The attributes can be optionally be included in the comparison. Attributes capture things like line numbers of column offsets, so comparing them involves test whether the layout of the program text is the same. Since whitespace seems inessential for comparing ASTs, the default is to compare fields but not attributes.

ASTs are just Python objects that can be modified in arbitrary ways. The API for ASTs is under-specified in the presence of user modifications to objects. The comparison respects modifications to fields and attributes, and to _fields and _attributes attributes. A user could create obviously malformed objects, and the code will probably fail with an AttributeError when that happens. (For example, adding "spam" to _fields but not adding a "spam" attribute to the object.) 

Co-authored-by: Jeremy Hylton <jeremy@alum.mit.edu>
2024-05-22 01:39:26 +00:00
..
2.0.rst gh-101100: Fix Sphinx warnings in whatsnew/2.0.rst (#112351) 2024-02-25 02:45:56 -07:00
2.1.rst gh-101100: Fix Sphinx warnings in whatsnew/2.1.rst (#112357) 2024-02-25 23:49:04 -07:00
2.2.rst gh-101100: Fix Sphinx warnings from PEP 3108 stdlib re-organisation (#114327) 2024-02-04 09:45:35 +00:00
2.3.rst Add 'The Python 2.3 Method Resolution Order' (#116435) 2024-04-15 13:01:15 +03:00
2.4.rst gh-101100: Fix Sphinx warnings from PEP 3108 stdlib re-organisation (#114327) 2024-02-04 09:45:35 +00:00
2.5.rst gh-101100: Fix Sphinx warnings from PEP 3108 stdlib re-organisation (#114327) 2024-02-04 09:45:35 +00:00
2.6.rst Docs: add link roles with Sphinx extlinks (#117850) 2024-04-15 21:22:00 +03:00
2.7.rst Docs: add link roles with Sphinx extlinks (#117850) 2024-04-15 21:22:00 +03:00
3.0.rst gh-101100: Fix Sphinx warnings from PEP 3108 stdlib re-organisation (#114327) 2024-02-04 09:45:35 +00:00
3.1.rst gh-101100: Fix Sphinx warnings in whatsnew/3.1.rst (#115575) 2024-02-17 02:39:07 -07:00
3.2.rst gh-118671: Updated dead ActiveState links (#118730) 2024-05-08 01:06:38 -06:00
3.3.rst gh-113664: Improve style of Big O notation (GH-113695) 2024-01-10 15:01:18 +02:00
3.4.rst Docs: mark up NotImplemented using the :data: role throughout the docs (#116135) 2024-02-29 20:46:12 +00:00
3.5.rst Docs: add link roles with Sphinx extlinks (#117850) 2024-04-15 21:22:00 +03:00
3.6.rst gh-100734: What's New in 3.x: Add missing detail from 3.x branch (#114689) 2024-02-15 17:32:33 +02:00
3.7.rst gh-101100: Fix Sphinx warnings in whatsnew/3.9.rst (#118364) 2024-04-28 20:31:22 +03:00
3.8.rst Docs: add link roles with Sphinx extlinks (#117850) 2024-04-15 21:22:00 +03:00
3.9.rst gh-101100: Fix Sphinx warnings in whatsnew/3.9.rst (#118364) 2024-04-28 20:31:22 +03:00
3.10.rst gh-101100: Fix Sphinx warnings in whatsnew/3.10.rst (#118356) 2024-04-28 18:12:25 +00:00
3.11.rst Docs: add link roles with Sphinx extlinks (#117850) 2024-04-15 21:22:00 +03:00
3.12.rst gh-118803: Remove ByteString from typing and collections.abc (#118804) 2024-05-09 00:37:55 +01:00
3.13.rst Docs: Add central references to free-threading-related options (#119017) 2024-05-21 17:49:23 -04:00
3.14.rst gh-60191: Implement ast.compare (#19211) 2024-05-22 01:39:26 +00:00
changelog.rst
index.rst Fix file extensions for 3.14 Whats New (#118770) 2024-05-08 16:40:40 +00:00