Skip to content

Make loops work in Python 3.10 #139

@laike9m

Description

@laike9m

Python 3.10 removes the jump by duplicating some instructions at the loop's start. This way, there's only 1 jump when the loop exits, instead of 2 (to head then out). And for every loop iteration, there's one less instruction to run, which is JUMP_ABSOLUTE

image

from cyberbrain import trace

@trace
def run_while():
    i = 0
    while i < 2:
        a = i
        i += 1


run_while()

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions