Skip to content

split compiler.c into compiler and codegen #121404

Closed

Description

@iritkatriel

compile.c is one of the largest source files in python (at about 8000 lines). Most of the code is code generation functions (the AST traversals). Most of the complexity is in the compiler data structure management.

In this work I will split out the code generation functions into a separate file so that they are independent of the compiler internals (access the compiler through an opaque reference and a well defined API). First I will transform the codegen functions so that they no longer access internals of struct compiler or struct compiler_unit. Then I will rename compile.c to codegen.c (to preserve commit history for the codegen functions) and copy out the compiler implementation code to a new file (compile.c, so the entry point is where people are used to finding it).

The benefits will be that (1) codegen code is simpler (2) the complexity of compile.c is more manageable as it will probably only span 2-3K lines of code (3) it becomes possible to share parts of the compiler with alternative compiler implementation.

Linked PRs

Activity

  1. self-assigned this
    on Jul 5, 2024
  2. added 6 commits that reference this issue on Jul 5, 2024
  3. added 2 commits that reference this issue on Jul 11, 2024
  4. added 2 commits that reference this issue on Jul 17, 2024
  5. added 3 commits that reference this issue on Jul 22, 2024
  6. 35 remaining items

  7. added 7 commits that reference this issue on Aug 30, 2024
  8. added a commit that references this issue on Sep 10, 2024
  9. added 2 commits that reference this issue on Sep 15, 2024
  10. added a commit that references this issue on Sep 22, 2024
  11. added a commit that references this issue on Oct 8, 2024
  12. added a commit that references this issue on Oct 8, 2024
  13. added a commit that references this issue on Oct 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

interpreter-core(Objects, Python, Grammar, and Parser dirs)

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions