Writing Python like it's Rust

This page summarizes the projects mentioned and recommended in the original post on news.ycombinator.com

Our great sponsors
  • Sonar - Write Clean Python Code. Always.
  • InfluxDB - Collect and Analyze Billions of Data Points in Real Time
  • Mergify - Updating dependencies is time-consuming.
  • pyre-check

    Performant type-checking for python.

  • pytype

    A static type analyzer for Python code

    What is the smart money doing for type checking in Python? I've used mypy which seems to work well but is incredibly slow (3-4s to update linting after I change code). I've tried pylance type checking in VS Code, which seems to work well + fast but is less clear and comprehensive than mypy. I've also seen projects like pytype [1] and pyre [2] used by Google/Meta, but people say those tools don't really make sense to use unless you're an engineer for those companies.

    Am just curious if mypy is really the best option right now?

    [1] https://github.com/google/pytype

  • Sonar

    Write Clean Python Code. Always.. Sonar helps you commit clean code every time. With over 225 unique rules to find Python bugs, code smells & vulnerabilities, Sonar finds the issues while you focus on the work.

  • sdk

    Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI (by dotnet)

    Another difference you might be surprised by is that the .NET tooling by default collects various data from your system and sends it to Microsoft [1]. If you want to avoid this (and still want to use .NET) you'll have to make sure that the environment variable DOTNET_CLI_TELEMETRY_OPTOUT is set in all contexts before touching anything.

    [1] https://github.com/dotnet/sdk/issues/6145

  • ruff

    An extremely fast Python linter, written in Rust.

    Ruff [0] is the best linter around for performance but I'm not sure how well it fills the static analysis role.

    [0] https://github.com/charliermarsh/ruff

  • pylance-release

    Documentation and issues for Pylance

    Maybe they "are the same thing" in terms of behavior (I don't know), but "A uses B" doesn't mean that "A is B".

    One important difference in this case is that while "Pylance leverages Microsoft's open-source static type checking tool, Pyright" [1], Pylance itself is not open source. In fact, the license [2] restricts you to "use [...] the software only with [...] Microsoft products and services", which means that you are not allowed to use it with a non-Microsoft open source fork of VS Code, for example.

    The license terms also say that by accepting the license, you agree that "The software may collect information about you and your use of the software, and send that to Microsoft" and that "You may opt-out of many of these scenarios, but not all".

    [1] https://github.com/microsoft/pylance-release

    [2] https://marketplace.visualstudio.com/items/ms-python.vscode-...

  • Nim

    Nim is a statically typed compiled systems programming language. It combines successful concepts from mature languages like Python, Ada and Modula. Its design focuses on efficiency, expressiveness, and elegance (in that order of priority).

    Personally, I switched to Go and soon after to Nim. https://nim-lang.org/

  • jaxtyping

    Type annotations and runtime checking for shape and dtype of JAX/NumPy/PyTorch/etc. arrays.

    Try using [jaxtyping](https://github.com/google/jaxtyping).

    It also supports numpy/pytorch/etc.

  • InfluxDB

    Collect and Analyze Billions of Data Points in Real Time. Manage all types of time series data in a single, purpose-built database. Run at any scale in any environment in the cloud, on-premises, or at the edge.

  • mypy

    Optional static typing for Python

    I'm also 100% convinced most people who use mypy don't realize the myriad ways it just silently stopps typing things or just silently crashes with a 0 exit code. Even if you configure it to warn untyped functions etc. It will still just not work properly in some of circumstances and you will literally never know until you debug a bug that just happened to trigger it. There are over 1.4k open but tickets it's such a broken piece of software: https://github.com/python/mypy/issues?q=is%3Aissue+is%3Aopen...

    The involvement of Guido in mypy is such a tragedy.

  • mypyc

    Compile type annotated Python to fast C extensions

    That would be interesting! You might already be aware. But there's mypyc[0], which is an AOT compiler for Python code with type hints (that, IIRC, mypy uses to compile itself into a native extension).

    Wanted to give you a head-start on the lit-review for your students I guess :)

    [0] https://github.com/mypyc/mypyc

  • madtypes

    Python Type that raise TypeError at runtime

    Hei !

    This comment inspired me because I was working on data-types at my company at the moment and I realized how static typing would have really benefited us.

    So I made a library that does just that !


    I hope this will help some people !

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts