Python Developer News: Psycopg3, DataClasses, and Rust

·24m 13s
Shared point

Updated PostgreSQL Adapters

Transition to Psycopg3

• The Psycopg project has officially shifted focus, declaring Psycopg3 as the present-standard for PostgreSQL adapters, while relegating Psycopg2 to the status of a long-standing legacy tool.
Psycopg3 is built with a hybrid approach, utilizing Python for the bulk of the logic and C for performance optimization.
• Key technical upgrades include native asyncio support, enhanced type compatibility (including support for PostgreSQL multi-range types), and improved connection pooling.

Data Management and Tooling

Converting Dictionaries to Data Classes

• The DayCite library offers a simplified way to create dataclasses from dictionaries, facilitating cleaner integration with APIs.
• It provides support for nested structures, optional fields, and custom type hooks to transform data during parsing.
• While not a full-featured validation framework like Pydantic, it serves as an excellent, lightweight alternative for dictionary-to-object mapping.

Pip’s Move to Rust

• The developer community is exploring the future of pip with a new, early-stage project titled rip, a barebones implementation written entirely in Rust.
• The goal is to improve package resolution speed and metadata caching, currently integrating the Resolvo engine to handle complex dependencies.

Software Testing and Engineering

Eliminating Flaky Tests

• A recent discussion highlighted the common pitfalls of concurrency in testing, particularly how the Global Interpreter Lock (GIL) can mask race conditions.
• Developers are encouraged to use tools like PyTest-Repeat or FlakeFinder to repeatedly run suites and surface non-deterministic test failures.
• Techniques to harden tests include synthetic stress on the GIL switch interval and using statistical checks for floating-point comparisons.

"There's more hydrogen atoms in a single molecule of water than there are stars in the entire solar system."

Extra Topics

ProtonMail Bridge: A useful tool for integrating ProtonMail's end-to-end encrypted inbox into standard desktop clients like Sparkmail.
Sci-Fi Shorts: High-quality, independent science fiction storytelling via the Dust YouTube channel.
Programming Parody: A musical nod to American Pie by Dylan Beattie, capturing the historical evolution and frustrations of a programming career.

Topics

Chapters

5 chapters
Python Bytes
AI chat — answers grounded in episodes