See CPython Run: An Introduction to Your Python Interpreter

James Bennett explores the inner workings of the CPython interpreter, providing insights into how Python code is executed and what makes the interpreter essential for running Python programs.

North Bay Python26.4K views30:59

About this video

James Bennett https://2019.northbaypython.org/schedule/presentation/10/ Python is a pretty neat language, but without an interpreter it doesn't do much. And although lots of people use the CPython interpreter (which is the main implementation of the Python language) every day, its workings are still a mystery even to many experienced Python programmers. So rather than explain features of Python the language, this talk will cover the interpreter itself, how it runs your code, and how you can use knowledge of the interpreter to figure out why your Python code behaves the way it does. To get started, we'll briefly look at some real questions asked on Python forums, wondering about strange, or at least unexplained, behaviors of Python. Like: Why does a different way of writing the same code sometimes run faster? Why does the behavior of the `is` operator seem to be inconsistent for some kinds of values? And what's the deal with all those ".pyc" files Python likes to leave all over the place? How and where would we start looking for answers to these? Then we'll take a look at the overall life cycle of Python code. We'll start with Python source code, and see how Python parses it into an abstract syntax tree (AST), how you can ask Python to show you the AST for a given piece of code, and how to read and understand it. Next we'll look at the transformation from AST to Python bytecode, what a Python code object looks like and how it's built, and how you can access it and understand the bytecode. Finally we'll see how the CPython virtual machine runs the compiled bytecode, and what's going on as it does so. Then we'll dive into the infrastructure of the interpreter, pointing out where to go to see things like the low-level implementations of Python's built-in types, the bytecode interpreter loop, the AST and bytecode optimizers, and more, along with tips on how the interpreter's source code is organized and how to find and read things you're interested in. Finally we'll circle back to some of the original questions about Python behavior, and see how they can be answered by using knowledge of how the CPython interpreter works, along with tools and tactics for making it easier to dig into what Python's doing with your code, and references for further reading and learning. You might run a Python interpreter multiple times a day, but do you really know what it's doing while it runs your code? And if Python is doing something that seems strange, where might you start looking to figure out why? Come find out in this guided tour of how the CPython interpreter works! A Python conference north of the Golden Gate North Bay Python is a single-track conference with a carefully curated set of talks representing the diverse Python community and their different areas of interest. If a topic is less to your interest, or you've met some people you really want to sit down and chat with, we'll have plenty of areas away from the main theatre to catch up and chat. Our goal is to keep prices as low as possible. That means we won't be catering lunch. Instead, you can look forward to extra-long lunch breaks you can use to explore all of the great food options around the venue. Produced by NDV: https://youtube.com/channel/UCQ7dFBzZGlBvtU2hCecsBBg?sub_confirmation=1 Sat Nov 2 14:30:00 2019 at Mystic Theatre

Tags and Topics

This video is tagged with the following topics. Click any tag to explore more related content and discover similar videos:

Tags help categorize content and make it easier to find related videos. Browse our collection to discover more content in these categories.

4.6

5 user reviews

Write a Review

0/1000 characters

User Reviews

0 reviews

Be the first to comment...

Video Information

Views
26.4K

Total views since publication

Likes
1.0K

User likes and reactions

Duration
30:59

Video length

Published
Nov 4, 2019

Release date

Quality
hd

Video definition

Related Trending Topics

LIVE TRENDS

This video may be related to current global trending topics. Click any trend to explore more videos about what's hot right now!

THIS VIDEO IS TRENDING!

This video is currently trending in Morocco under the topic 'météo demain'.

Share This Video

SOCIAL SHARE

Share this video with your friends and followers across all major social platforms including X (Twitter), Facebook, Youtube, Pinterest, VKontakte, and Odnoklassniki. Help spread the word about great content!