<feed xmlns='http://www.w3.org/2005/Atom'>
<title>delta/cpython-git.git/Python/ast_opt.c, branch travis-macOS</title>
<subtitle>github.com: python/cpython.git
</subtitle>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/cpython-git.git/'/>
<entry>
<title>bpo-33416: Add end positions to Python AST (GH-11605)</title>
<updated>2019-01-22T11:18:22+00:00</updated>
<author>
<name>Ivan Levkivskyi</name>
<email>levkivskyi@gmail.com</email>
</author>
<published>2019-01-22T11:18:22+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/cpython-git.git/commit/?id=9932a22897ef9905161dac7476e6976370e13515'/>
<id>9932a22897ef9905161dac7476e6976370e13515</id>
<content type='text'>
The majority of this PR is tediously passing `end_lineno` and `end_col_offset` everywhere. Here are non-trivial points:
* It is not possible to reconstruct end positions in AST "on the fly", some information is lost after an AST node is constructed, so we need two more attributes for every AST node `end_lineno` and `end_col_offset`.
* I add end position information to both CST and AST.  Although it may be technically possible to avoid adding end positions to CST, the code becomes more cumbersome and less efficient.
* Since the end position is not known for non-leaf CST nodes while the next token is added, this requires a bit of extra care (see `_PyNode_FinalizeEndPos`). Unless I made some mistake, the algorithm should be linear.
* For statements, I "trim" the end position of suites to not include the terminal newlines and dedent (this seems to be what people would expect), for example in
  ```python
  class C:
      pass

  pass
  ```
  the end line and end column for the class definition is (2, 8).
* For `end_col_offset` I use the common Python convention for indexing, for example for `pass` the `end_col_offset` is 4 (not 3), so that `[0:4]` gives one the source code that corresponds to the node.
* I added a helper function `ast.get_source_segment()`, to get source text segment corresponding to a given AST node. It is also useful for testing.

An (inevitable) downside of this PR is that AST now takes almost 25% more memory. I think however it is probably justified by the benefits.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The majority of this PR is tediously passing `end_lineno` and `end_col_offset` everywhere. Here are non-trivial points:
* It is not possible to reconstruct end positions in AST "on the fly", some information is lost after an AST node is constructed, so we need two more attributes for every AST node `end_lineno` and `end_col_offset`.
* I add end position information to both CST and AST.  Although it may be technically possible to avoid adding end positions to CST, the code becomes more cumbersome and less efficient.
* Since the end position is not known for non-leaf CST nodes while the next token is added, this requires a bit of extra care (see `_PyNode_FinalizeEndPos`). Unless I made some mistake, the algorithm should be linear.
* For statements, I "trim" the end position of suites to not include the terminal newlines and dedent (this seems to be what people would expect), for example in
  ```python
  class C:
      pass

  pass
  ```
  the end line and end column for the class definition is (2, 8).
* For `end_col_offset` I use the common Python convention for indexing, for example for `pass` the `end_col_offset` is 4 (not 3), so that `[0:4]` gives one the source code that corresponds to the node.
* I added a helper function `ast.get_source_segment()`, to get source text segment corresponding to a given AST node. It is also useful for testing.

An (inevitable) downside of this PR is that AST now takes almost 25% more memory. I think however it is probably justified by the benefits.</pre>
</div>
</content>
</entry>
<entry>
<title>bpo-35177: Add dependencies between header files (GH-10361)</title>
<updated>2018-11-11T23:56:19+00:00</updated>
<author>
<name>Victor Stinner</name>
<email>vstinner@redhat.com</email>
</author>
<published>2018-11-11T23:56:19+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/cpython-git.git/commit/?id=5f2df88b63e50d23914e97ec778861a52abdeaad'/>
<id>5f2df88b63e50d23914e97ec778861a52abdeaad</id>
<content type='text'>
* ast.h now includes Python-ast.h and node.h
* parsetok.h now includes node.h and grammar.h
* symtable.h now includes Python-ast.h
* Modify asdl_c.py to enhance Python-ast.h:

  * Add #ifndef/#define Py_PYTHON_AST_H to be able to include the header
    twice
  * Add "extern { ... }" for C++
  * Undefine "Yield" macro conflicting with winbase.h

* Remove "#undef Yield" from C files, it's now done in Python-ast.h
* Remove now useless includes in C files</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* ast.h now includes Python-ast.h and node.h
* parsetok.h now includes node.h and grammar.h
* symtable.h now includes Python-ast.h
* Modify asdl_c.py to enhance Python-ast.h:

  * Add #ifndef/#define Py_PYTHON_AST_H to be able to include the header
    twice
  * Add "extern { ... }" for C++
  * Undefine "Yield" macro conflicting with winbase.h

* Remove "#undef Yield" from C files, it's now done in Python-ast.h
* Remove now useless includes in C files</pre>
</div>
</content>
</entry>
<entry>
<title>bpo-32892: Use ast.Constant instead of specific constant AST types. (GH-9445)</title>
<updated>2018-09-27T14:42:37+00:00</updated>
<author>
<name>Serhiy Storchaka</name>
<email>storchaka@gmail.com</email>
</author>
<published>2018-09-27T14:42:37+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/cpython-git.git/commit/?id=3f22811fef73aec848d961593d95fa877f77ecbf'/>
<id>3f22811fef73aec848d961593d95fa877f77ecbf</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>bpo-33691: Add _PyAST_GetDocString(). (GH-7236)</title>
<updated>2018-05-30T07:56:16+00:00</updated>
<author>
<name>Serhiy Storchaka</name>
<email>storchaka@gmail.com</email>
</author>
<published>2018-05-30T07:56:16+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/cpython-git.git/commit/?id=143ce5c6db77a0b9d451b8463dee6752358a9ea4'/>
<id>143ce5c6db77a0b9d451b8463dee6752358a9ea4</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>bpo-32911: Revert bpo-29463. (GH-7121) (GH-7197)</title>
<updated>2018-05-29T09:04:55+00:00</updated>
<author>
<name>Serhiy Storchaka</name>
<email>storchaka@gmail.com</email>
</author>
<published>2018-05-29T09:04:55+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/cpython-git.git/commit/?id=73cbe7a01a22d02dbe1ec841e8779c775cad3d08'/>
<id>73cbe7a01a22d02dbe1ec841e8779c775cad3d08</id>
<content type='text'>
Remove the docstring attribute of AST types and restore docstring
expression as a first stmt in their body.

Co-authored-by: INADA Naoki &lt;methane@users.noreply.github.com&gt;</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Remove the docstring attribute of AST types and restore docstring
expression as a first stmt in their body.

Co-authored-by: INADA Naoki &lt;methane@users.noreply.github.com&gt;</pre>
</div>
</content>
</entry>
<entry>
<title>bpo-32925: Optimized iterating and containing test for literal lists (GH-5842)</title>
<updated>2018-03-11T08:54:47+00:00</updated>
<author>
<name>Serhiy Storchaka</name>
<email>storchaka@gmail.com</email>
</author>
<published>2018-03-11T08:54:47+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/cpython-git.git/commit/?id=3f7e9aa2ef215917b9f1521441f67f4ecd33a1bc'/>
<id>3f7e9aa2ef215917b9f1521441f67f4ecd33a1bc</id>
<content type='text'>
consisting of non-constants: `x in [a, b]` and `for x in [a, b]`.
The case of all constant elements already was optimized.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
consisting of non-constants: `x in [a, b]` and `for x in [a, b]`.
The case of all constant elements already was optimized.
</pre>
</div>
</content>
</entry>
<entry>
<title>bpo-9566: Fix size_t=&gt;int downcast warnings (#5230)</title>
<updated>2018-01-18T10:15:25+00:00</updated>
<author>
<name>Victor Stinner</name>
<email>victor.stinner@gmail.com</email>
</author>
<published>2018-01-18T10:15:25+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/cpython-git.git/commit/?id=05d68a8bd84cb141be9f9335f5b3540f15a989c4'/>
<id>05d68a8bd84cb141be9f9335f5b3540f15a989c4</id>
<content type='text'>
* Use wider types (int =&gt; Py_ssize_t) to avoid integer overflows.
* Fix gc.get_freeze_count(): use Py_ssize_t type rather than int, since gc_list_size() returns a Py_ssize_t.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* Use wider types (int =&gt; Py_ssize_t) to avoid integer overflows.
* Fix gc.get_freeze_count(): use Py_ssize_t type rather than int, since gc_list_size() returns a Py_ssize_t.</pre>
</div>
</content>
</entry>
<entry>
<title>bpo-32372: Move __debug__ optimization to the AST level. (#4925)</title>
<updated>2017-12-25T10:47:50+00:00</updated>
<author>
<name>Serhiy Storchaka</name>
<email>storchaka@gmail.com</email>
</author>
<published>2017-12-25T10:47:50+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/cpython-git.git/commit/?id=3dfbaf51f0d90646e0414ddbd3b513ee8e5ffe9b'/>
<id>3dfbaf51f0d90646e0414ddbd3b513ee8e5ffe9b</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>bpo-30416: Protect the optimizer during constant folding. (#4860)</title>
<updated>2017-12-15T12:11:43+00:00</updated>
<author>
<name>Serhiy Storchaka</name>
<email>storchaka@gmail.com</email>
</author>
<published>2017-12-15T12:11:43+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/cpython-git.git/commit/?id=2e3f5701858d1fc04caedefdd9a8ea43810270d2'/>
<id>2e3f5701858d1fc04caedefdd9a8ea43810270d2</id>
<content type='text'>
It no longer spends much time doing complex calculations and no
longer consumes much memory for creating large constants that will
be dropped later.

This fixes also bpo-21074.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
It no longer spends much time doing complex calculations and no
longer consumes much memory for creating large constants that will
be dropped later.

This fixes also bpo-21074.
</pre>
</div>
</content>
</entry>
<entry>
<title>bpo-29469: Optimize literal lists and sets iterating on the AST level. (#4866)</title>
<updated>2017-12-14T18:24:31+00:00</updated>
<author>
<name>Serhiy Storchaka</name>
<email>storchaka@gmail.com</email>
</author>
<published>2017-12-14T18:24:31+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/cpython-git.git/commit/?id=15a8728415e765f57e37f431f09e5c5821a04063'/>
<id>15a8728415e765f57e37f431f09e5c5821a04063</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
</feed>
