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

August 18, 2024 • Frank Valcarcel

What makes Enterprise Software Development Different?

Enterprise software powers large organizations, handling complex tasks across departments. From robust security to scalability, these solutions face unique challenges. Explore what makes software “enterprise-ready” and how to choose the right development approach for your business.

Image for 'This Week I Learned' blog post featuring tips on managing Git branches including renaming and syncing with remote changes.
October 8, 2019 • Frank Valcarcel

TWIL 2019-10-04

Join us for ‘TWIL,’ where Emily shares innovative Git tips for managing branches with rewritten history. Learn to sync local branches with remote changes and rename them effectively.