basedpython¶
a python-like language that transpiles to pure python — sum types, extensions, optional chaining and a type system that knows what your code means, lowered to files any python tool can read
- a python type checker with framework support — pydantic, sqlalchemy, pytest and django are modelled directly, so the magic they do at runtime checks like ordinary code
- basedpython, a python-like language that builds into python wheels
- compiles into high performance python extension modules
- a language server, formatter and linter —
by serverdrives the editor, andbuffis the basedpython build of ruff
enum class Shape:
case Circle(radius: int)
case Rect(width: int, height: int)
def area(self) -> int:
return match self:
case Shape.Circle(r):
3 * r * r
case Shape.Rect(w, h):
w * h
extension list[Element: Shape]:
def first_circle(self) -> Shape.Circle?:
for shape in self:
if shape is Shape.Circle:
return shape
return None
def stats(shapes: list[Shape]) -> (count: int, total: int):
return (len(shapes), sum(s.area() for s in shapes))
def main():
let shapes = [Shape.Circle(1), Shape.Rect(2, 3)]
let summary = stats(shapes)
print(f"{summary.count} shapes, {summary.total} total")
print(shapes.first_circle()?.radius ?? 0)
what you get¶
-
plain python out the other end
by buildwrites ordinary.pyfiles. pytest, mypy, ruff and everything else in your stack keep working, because what they see is python -
syntax python doesn't have
sum types with payloads, extension methods, destructuring, trailing lambda blocks,
?.,??, and properties that read like declarations -
a type system that keeps up
intersections, negations, match types, symbolic arithmetic in type parameters, and inference that narrows instead of shrugging
-
frameworks understood, not tolerated
pydantic, sqlalchemy, pytest and django are modelled directly, so synthesized constructors and injected fixtures check like real code
where to go¶
-
install, your first
.byfile, project layout, and wiringby buildinto CI -
the full language reference, one page per feature
-
where settings live and how they resolve
-
what basedpython knows about pydantic, sqlalchemy, pytest and django
-
every place the same source means something different in a
.byfile -
every command and flag the
bydriver adds
credits for contributors and the third-party work basedpython relies on