Skip to Main Content
PyCon
Conference Talks
Python
The PyCon 2018 logo, where Cuttlesoft Co-founder, Emily Morehouse delivered a talk about abstract syntax trees in CPython.

Diving Deep into Python's Abstract Syntax Tree with Emily Morehouse

At PyCon 2018, Cuttlesoft's Director of Engineering, Emily Morehouse, spoke to a packed Cleveland conference hall full of Python professionals and fans. The room fell silent with anticipation as Emily prepared to unravel the mysteries of Python's Abstract Syntax Tree (AST) in her talk titled "The AST and Me."

Understanding the Python Code Lifecycle

For many people, the path of Python code is a mystery. Python code goes through many changes from source code to its ultimate execution. Emily stressed the value of comprehending the inner workings of the language while giving guests a unique look into this process.

"Python is both a compiled and an interpreted language"

This duality is what makes Python beautiful and complex. The phases that Python code goes through are tokenization, parsing, abstract syntax tree conversion, bytecode production, and eventually execution in the Python virtual machine.

The Magic of the Abstract Syntax Tree

Emily's thorough explanation of the Abstract Syntax Tree (AST) was the talk's high point. An AST is a simplified tree-like representation of code by definition. Each node in this tree represents a specific language construct, providing a clear structural representation of the code.

"Think of the AST as a more distilled version of the parse tree, which retains all information, including comments, from the source code,"

By simplifying and organizing the source code, ASTs offer developers a powerful tool to interact with and comprehend the underlying semantics of the code.

Optimizing Python Compilation

Another noteworthy aspect of the talk was Emily's insights into the current optimizations in Python's compilation process. By understanding these optimizations, developers can write more efficient code and fully utilize the power of Python.

Harnessing the Power of ASTs

Emily demonstrated various ways developers can use ASTs to build powerful tools. Drawing from her vast experience at Cuttlesoft, she showcased real-world applications of ASTs and encouraged fellow developers to embark on this journey of exploration.

"By grasping the intricacies of the Abstract Syntax Tree, developers open doors to creating more efficient, powerful, and innovative tools"

Slides for Emily's talk can be found at: https://speakerdeck.com/pycon2018 and https://github.com/PyCon/2018-slides.

Related Posts

Schematic drawing representing the structure of React's compound components.
October 26, 2020 • Marisa Gomez

Mastering Compound Components in React

Discover React’s compound components, blending flexibility and expressiveness. Learn to manage states while controlling rendering, and see how React hooks enhance this method.

Close up depiction of tree branches illustrating branching in Git for improved software documentation management.
April 24, 2017 • Nick Farrell

Using Git to Manage Software Documentation

Word processors are all fine products that do what they’re meant to do. However, technical writers should consider Git when writing documentation — here’s why!