We're sunsetting PodQuest on 2025-07-28. Thank you for your support!
Export Podcast Subscriptions
cover of episode 216: ruff, uv, and Astral: Python tooling, much faster, with Rust

216: ruff, uv, and Astral: Python tooling, much faster, with Rust

2024/3/11
logo of podcast Test & Code

Test & Code

AI Deep Dive AI Insights AI Chapters Transcript
People
C
Charlie Marsh
主持人
专注于电动车和能源领域的播客主持人和内容创作者。
Topics
主持人:我关注的是使用Rust来加速Python工具,特别是对于那些经常使用pip或创建虚拟环境的开发者,速度的提升会显著改善日常工作流程。 Charlie Marsh:我从2022年夏天开始开发Ruff,最初的目标是验证用Rust构建更快的Python工具的可能性。Ruff整合了多个工具的功能,例如Flake8、isort和Black,并提供了更高的性能。它的优势在于性能和整合性,它将多个工具的功能整合到一个工具中,简化了工具链。Ruff发布后增长迅速,因为它满足了人们对更快、更高性能Python工具的需求。Astral公司的目标是构建统一且高性能的Python工具,我们的愿景是创建一个单一的二进制文件,包含Python开发所需的一切工具,并在此基础上构建和销售服务。目前公司没有营收,依靠风险投资运作,未来的盈利模式是基于开源工具构建和销售服务,例如私有注册表或与我们的工具良好集成的CI/CD解决方案。 UV是pip、pip-tools和virtualenv的替代品,但目前其抽象级别不如Poetry或PDM。UV的设计目标是速度,力求比现有工具快10倍。UV的缓存机制是将所有项目中安装的包存储在一个全局存储中,从而提高速度和空间效率。UV使用pip作为子命令是为了让用户更容易理解其CLI和命令。UV并非旨在完全兼容pip、pip-tools和virtualenv,而是力求在很大程度上兼容,并提供更简化的用户界面。UV使用子命令是为了在未来添加更高级别的命令,而不会破坏现有功能。拥有多个可行的包安装程序对Python生态系统是有益的。当前的重点是修复UV的bug,未来的一个重要功能是支持引导和管理Python版本。在Ruff方面,计划改进Ruff的编辑器集成,特别是将语言服务器重写为Rust。

Deep Dive

Key Insights

What is Ruff and how does it improve Python tooling?

Ruff is a Python tooling tool that can replace Flake8, isort, and Black, offering over 700 rules for linting and formatting. It is built using Rust, making it significantly faster than traditional Python tools. Ruff simplifies the toolchain by bundling multiple functionalities into one tool, reducing the need to learn and manage multiple disparate tools.

How does UV differ from traditional Python packaging tools like pip and virtualenv?

UV is a Rust-based tool that serves as a faster alternative to pip, pip-tools, and virtualenv. It uses a global cache to store packages, reducing disk space and speeding up installations through symlinking and copy-on-write techniques. While it is not as abstracted as tools like Poetry or PDM, it provides a more performant and unified experience for managing Python dependencies and environments.

Why was Rust chosen for building Python tools like Ruff and UV?

Rust was chosen for its speed and performance benefits, which are crucial for improving the efficiency of Python tooling. The trend of using Rust in other programming ecosystems, such as JavaScript, inspired its adoption. Rust's ability to integrate with Python allows for the creation of faster and more robust tools, addressing the performance bottlenecks in traditional Python toolchains.

What is Astral and what is its mission?

Astral is a venture-backed company founded by Charlie Marsh, focused on building high-performance Python tooling. Its mission is to create unified and faster Python tools, such as Ruff and UV, and to bring more innovation and experimentation into the Python ecosystem. Astral aims to provide a cohesive experience where users can bootstrap Python and access all necessary tools from a single binary.

How does UV's caching mechanism improve performance compared to pip?

UV uses a global cache to store packages, which allows it to link the same package across multiple projects instead of downloading or copying it repeatedly. This approach, using symlinking and copy-on-write, significantly reduces installation time and disk space usage. It contrasts with pip's caching mechanism, which often involves redundant downloads and storage of packages.

What are Astral's future plans for UV?

Astral plans to expand UV's capabilities to include bootstrapping and managing Python versions, allowing users to download and install Python directly through UV. This feature aims to simplify the process of setting up Python environments and ensure compatibility with the required Python versions for projects. Additionally, Astral is focusing on improving editor integrations and making the UV roadmap more public for community feedback.

How does Ruff handle code formatting compared to Black?

Ruff includes a built-in formatter called Ruff Format, which is largely compatible with Black. While it does not aim to innovate on code style, it focuses on providing a faster and more unified experience. Users can configure Ruff to handle both linting and formatting, reducing the need to learn and manage separate tools like Black and Flake8.

What challenges did Charlie Marsh face transitioning into the Python open-source community?

Charlie Marsh faced a steep learning curve transitioning into the Python open-source community, as he had not previously been an active participant. He had to learn how to be a maintainer, engage in PEP discussions, and build relationships within the ecosystem. This shift was a significant change from his previous roles as a Python user in various companies.

How does Astral plan to monetize its open-source tools?

Astral currently does not generate revenue and is venture-backed. The company plans to build services on top of its open-source tools, such as private package hosting or CI/CD solutions, that integrate seamlessly with Ruff and UV. These services will remain optional, ensuring that the core tools stay open source and free for all users.

What is the significance of UV's name and its connection to Astral?

UV stands for 'ultraviolet,' which ties into Astral's branding by referencing light and celestial themes. The name was chosen for its brevity and ease of typing, as it is short and located near the home row on keyboards. Unlike Ruff, which predates Astral, UV was intentionally named to align with the company's brand identity.

Shownotes Transcript

Charlie Marsh and team are using Rust to make Python tooling faster.

  • Ruff can take the place of Flake8, isort, and Black, and so much more.
  • uv can take the place of pip, pip-tools, and virtualenv
  • Astral is Charlie's venture backed company, and what they have with ruff and uv is just the start.

Since uv is the newest tool, there's quite a bit of the discussion diving into uv.

Links:

** Learn pytest**