Building your DSL compiler in Python - Mateusz Sokół

EuroPython Conference
295 views •

[EuroPython 2026 - S3B on 2026-07-17] šŸŽ¤ *Building your DSL compiler in Python by Mateusz Sokół* šŸ”— https://ep2026.europython.eu/session/building-your-dsl-compiler-in-python šŸ“ Abstract: A multitude of Python libraries offer Just In Time (JIT) compilation capabilities for general purpose computations, such as JAX or Numba. But in certain cases these solutions might not be enough, thus we seek more specialized solutions that can include domain knowledge as well. Compilers for Domain Specific Languages (DSL) allow us to incorporate additional information during compilation, possibly tied to a specific domain, such as sparse arrays computing. In this talk I'm going to introduce [Finch](https://finch-tensor.org/) - language and a compiler for sparse and structured multidimensional arrays, which specializes its kernels for control flow and data structures. It supports common control flow (loops, if conditions, etc.) and a wide variety of data structures - dense, sparse list, triangles, coordinate, or symmetry. The ongoing effort to move Finch from the original Julia implementation to pure Python exposed us to new ways of using Python - as a language for implementing compilers. In this talk I will present some key aspects of Python language and ecosystem which played a central role in making us productive in the last months during this undertaking: - Defining IRs with dataclasses and utilizing Structural Pattern Matching for term rewriting, - Using [Lark](https://lark-parser.readthedocs.io/en/stable/) for parsing custom languages into large IR structures, - Expressing complex rewrite schemes with [rewrite-tools](https://pypi.org/project/rewrite-tools/). The audience will learn our approach to designing the structure of a compiler, together with a few technical decisions made along the way. I hope these insights will be useful for engineers and scientists coming from closely related fields and projects also involving compiling custom languages, such as probabilistic programming or hardware design. --- This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License: https://creativecommons.org/licenses/by-nc-sa/4.0/

Keyboard shortcuts

On. Switch them off if they collide with your assistive tools; ? still opens this sheet.

Go to

Press g then the letter.

  • gh Latest
  • gs Sources
  • gm Media
  • gv Videos
  • gp Podcasts
  • gc Calendar
  • gd Decoder
  • gz Dataviz
  • ga Datasets
  • gb Blog
  • gk Markets
  • gj Careers
  • gn Prompt Notebook

On this page

  • / Focus search, where there is one
  • t Back to top
  • ? This list
  • Esc Close