We're sunsetting PodQuest on 2025-07-28. Thank you for your support!
Export Podcast Subscriptions
cover of episode #413 python-build-standalone finds a home

#413 python-build-standalone finds a home

2024/12/9
logo of podcast Python Bytes

Python Bytes

AI Deep Dive AI Insights AI Chapters Transcript
People
B
Brian
Python 开发者和播客主持人,专注于测试和软件开发教育。
M
Michael
帮助医生和高收入专业人士管理财务的金融教育者和播客主持人。
Topics
Michael: Jiter是一个快速迭代的JSON解析器,由Pydantic团队开发,用于Pydantic和OpenAI项目。它提供三种接口:JsonValue、Jiter和PythonParse,能够高效处理JSON数据,尤其是在处理LLM分阶段输出时表现出色。其速度甚至超过了默认的Rust JSON解析器。 Brian: python-build-standalone项目已转移到Astral维护,这将提高其稳定性,并对依赖它的项目(如uv)产生积极影响。Astral计划更新项目以适应最新的Python版本和CPython构建系统,并解决一些现有限制。该项目已被下载超过7000万次,在Python包管理中扮演着关键角色。 Brian: uv是一个功能强大的Python包管理器,提供快速安装Python、创建虚拟环境和管理包的功能。文章介绍了uv的常用命令,以及如何将其整合到现有工作流程中,包括使用锁文件和固定依赖项等最佳实践。uv的优势在于其速度和一体化特性,简化了Python开发流程。 Michael: moka-py是一个基于Rust的Moka高性能缓存库的Python绑定。它提供同步缓存、TTL、TTI和基于大小的驱逐等功能,并支持同步和异步操作。Moka-py可以作为LRU缓存函数装饰器的替代方案,提高Python代码的性能。其性能在M1 Mac上测试,每秒可执行数百万次缓存获取和设置操作。

Deep Dive

Key Insights

Why is Jiter important for Pydantic and OpenAI?

Jiter is a fast, iterable JSON parser that serves as the backend for Pydantic and is used by OpenAI, including in their Python library for ChatGPT. It enhances the speed and efficiency of JSON data parsing, which is crucial for applications like Pydantic that validate and transform JSON data into Python classes.

What is the significance of Python Build Standalone moving to Astral?

Python Build Standalone, a project providing prebuilt binaries for different architectures, has moved to Astral, ensuring better stability and stewardship. This transition is crucial for tools like UV, pipx, and hatch, which rely on it for Python installations. Astral aims to keep the project up-to-date with Python releases and improve its build and release processes.

How does Mocha-Py enhance Python's caching capabilities?

Mocha-Py is a Python binding for the high-performance Mocha caching library written in Rust. It offers features like thread-safe, in-memory caching, TTL and TTI support, size-based eviction, and concurrency optimizations. Mocha-Py allows Python developers to leverage Mocha's efficient caching mechanisms, including a decorator for function-based caching, enhancing performance in multi-threaded environments.

What are the key features and commands of UV, Python's package manager?

UV is a fast and ambitious package manager for Python that simplifies various tasks including Python installation, virtual environment creation, package management, and dependency pinning. Key commands include 'uv python install' for installing Python, 'uv venv' for creating virtual environments, 'uv pip install' for package installation, and 'uv sync' for managing project dependencies and lock files.

Why should developers consider supporting open-source projects financially?

Supporting open-source projects financially can significantly contribute to their sustainability and improvement. For instance, if every user of a widely-used project like Flask or Gunicorn contributed a small amount, it could transform the project's development and maintenance. This support can ensure that critical tools remain healthy and well-maintained, benefiting the entire developer community.

Chapters
Jiter, a fast iterable JSON parser created by the Pydantic team, is used by OpenAI and offers three interfaces: JsonValue, Jiter, and PythonParse. Its speed and ability to parse partial data make it a valuable tool for handling JSON data efficiently.
  • Jiter is a fast, iterable JSON parser.
  • It's used by Pydantic and OpenAI.
  • It offers three interfaces: JsonValue, Jiter, and PythonParse.

Shownotes Transcript

Topics covered in this episode:

- [**jiter**](https://github.com/pydantic/jiter?featured_on=pythonbytes))

Watch on YouTube)

About the show

Sponsored by us! Support our work through:

Connect with the hosts

Join us on YouTube at pythonbytes.fm/live) to be part of the audience. Usually Monday at 10am PT. Older video versions available there too.

Finally, if you want an artisanal, hand-crafted digest of every week of the show notes in email form? Add your name and email to our friends of the show list), we'll never share it.

Michael #1: jiter)

  • Fast iterable JSON parser.

  • About to be the backend for Pydantic and Logfire.

  • Currently powers OpenAI / ChatGPT (along with Pydantic itself), at least their Python library, maybe more.

  • jiter has three interfaces:

  • JsonValue an enum representing JSON data

  • Jiter an iterator over JSON data

  • PythonParse which parses a JSON string into a Python object

  • jiter-python) - This is a standalone version of the JSON parser used in pydantic-core. The recommendation is to only use this package directly if you do not use pydantic

Brian #2: A new home for python-build-standalone)

Michael #3: moka-py)

  • A high performance caching library for Python written in Rust

  • moka-py is a Python binding for the highly efficient Moka) caching library written in Rust.

  • This library allows you to leverage the power of Moka's high-performance, feature-rich cache in your Python projects.

  • Features

  • Synchronous Cache: Supports thread-safe, in-memory caching for Python applications.

  • TTL Support: Automatically evicts entries after a configurable time-to-live (TTL).

  • TTI Support: Automatically evicts entries after a configurable time-to-idle (TTI).

  • Size-based Eviction: Automatically removes items when the cache exceeds its size limit using the TinyLFU policy.

  • Concurrency: Optimized for high-performance, concurrent access in multi-threaded environments.

Brian #4: uv: An In-Depth Guide)

  • On SaaS Pegasus blog, so presumably by Cory Zue

  • Good intro to uv

  • Also a nice list of everyday commands

  • Install python: uv python install 3.12

  • I don’t really use this anymore, as uv venv .venv --python 3.12 or uv sync install if necessary

  • create a virtual env: uv venv .venv --python 3.12

  • install stuff: uv pip install django

  • add project dependencies

  • build pinned dependencies

  • Also discussion about adopting the new workflow

Extras

Brian:

Michael:

Joke: Inf)