Skip to Main Content
Python
Conference Talks

Unveiling the Mysteries of Python's AST: Insights from PyCascades 2018

Exploring Python's Compilation Journey with Emily Morehouse

At the picturesque PyCascades conference in Vancouver, a notable event in the Python community, Emily Morehouse, co-founder and director of engineering at Cuttlesoft, delivered an enlightening talk titled "The AST and Me." Her presentation provided attendees with a deep dive into the world of Python's Abstract Syntax Tree (AST) and its critical role in Python's compilation process.

Understanding Python's Compilation: Is It Interpreted or Compiled?

Ever ponder whether Python is an interpreted or compiled language? Emily's talk sheds light on this ambiguity. In her words, Python is both. The journey from Python source code to execution is not a straight path but involves a complex compilation process. The key takeaway? Understanding Python's dynamic nature, where the same bytecode doesn't always yield the same outcome.

The Core of Python: Abstract Syntax Trees

What makes Emily's talk stand out is her ability to simplify complex concepts like ASTs. She explains that ASTs represent the structure of your source code but in a more manageable form than parse trees. This simplification is crucial for developers looking to delve into Python's internals and optimize their code's performance.

Python's Compilation Process: A Closer Look

Emily's expertise shines as she navigates through the intricacies of Python's compilation process. From transforming parse trees into ASTs and then into Control Flow Graphs (CFGs), her explanation is a treasure trove for developers seeking to optimize Python code. The conversion of ASTs into bytecode, which is then executed, is a critical phase where understanding can lead to significant performance improvements.

Practical Applications: Beyond Theory

The talk was not just about theory. Emily provided practical insights on how developers can use their understanding of ASTs to debug errors, improve code speed, and even inspect Python grammar. One of the highlights was the concept of "round-tripping" – ensuring that linting and other code modifications do not alter the underlying meaning of the code.

Python's Peephole Optimizations and Constant Folding

A segment of the talk that caught much attention was the discussion on Python's peephole optimizations and constant folding. Emily described how these compiler techniques simplify and optimize Python code, making it more efficient.

Embracing Python's Ecosystem: Tools and Resources

For Python developers eager to explore further, Emily mentioned several tools and libraries integral to working with Python's AST, such as the AST module and disassembler. She also highlighted resources like PyBee and Jinja, which leverage ASTs for various applications, from web programming to transpiling Python code into other languages.

Final Thoughts: A Journey of Learning and Sharing

Emily Morehouse's first conference talk was not just informative but also an inspiring journey for a first-time conference speaker. Her openness in sharing her learning process and resources is a testament to the Python community's collaborative spirit.

Explore More

To dive deeper into the fascinating world of Python's AST, check out Emily's slides: https://emilyemorehouse.github.io/ast-and-me/

Related Posts

March 19, 2018 • Frank Valcarcel

Google Developer Group – Women Techmakers Lightning Talks

At Women Techmakers Day, hosted by the Google Developer Group in Boulder, Emily shares a deeply personal and insightful perspective on managing exhaustion and finding fulfillment.

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.