Top Python Libraries

Top Python Libraries

Share this post

Top Python Libraries
Top Python Libraries
How does a virtual machine execute bytecode?(Python Virtual Machine 3)
Copy link
Facebook
Email
Notes
More

How does a virtual machine execute bytecode?(Python Virtual Machine 3)

Learn how virtual machines execute bytecode, covering serialization, VM implementation, and the difference between interpretation and JIT compilation.

Meng Li's avatar
Meng Li
Feb 17, 2025
∙ Paid
1

Share this post

Top Python Libraries
Top Python Libraries
How does a virtual machine execute bytecode?(Python Virtual Machine 3)
Copy link
Facebook
Email
Notes
More
1
Share

"Top Python Libraries" publication New Year 20% discount link.


Python Inner Workings: From Code to Execution

Welcome to the "Python Virtual Machine" Series

Table of Contents

Table of Contents

Meng Li
·
July 12, 2024
Read full story

In the previous lesson, we introduced how the compiler translates source code into bytecode. In this lesson, we will continue with the example from the previous lesson to implement a simple virtual machine that will run the generated bytecode.

Let's first take a look at the bytecode defined in the previous lesson.

#define BINARY_MUL      20
#define BINARY_DIV      21
#define BINARY_ADD      23
#define BINARY_SUB      24

#define LOAD_CONST 100

At the end of the last lesson, the generated bytecode was [100, 00, 12, 100, 00, 48, 20, 100, 00, 59, 23]. Let's decode this bytecode.

LOAD_CONST      12
LOAD_CONST      48
BINARY_MUL
LOAD_CONST      59
BINARY_ADD

This post is for paid subscribers

Already a paid subscriber? Sign in
© 2025 Meng Li
Privacy ∙ Terms ∙ Collection notice
Start writingGet the app
Substack is the home for great culture

Share

Copy link
Facebook
Email
Notes
More