Discover a fascinating new Python library that ensures long-running tasks are resilient by saving their state in a Postgres database. Explore the rise of typing in Python as developers adopt it widely, but face usability hurdles. Learn about tools like Write Typer, perfect for automating type annotations. Dive into the integration of command line utilities in scripts, and hear tips on productivity enhancements. Enjoy a lighthearted discussion of Python syntax with a twist, filled with humor and relatable coding terms.
DBOS Transact enhances Python's durable execution by ensuring workflows automatically resume from the last completed step after any interruption.
The rise of Typed Python in 2024 shows significant adoption among developers, though usability challenges indicate a need for better education on type hints.
Deep dives
Durable Software and Workflow Management
Durable software execution is essential for handling long-running processes efficiently, especially in Python. A system called 'dbos transact pi' facilitates this by allowing users to create workflows that automatically manage failures. By using a workflow decorator, steps are serialized into a Postgres database, enabling recovery from crashes and resuming at the last completed step. This approach minimizes downtime and ensures processes like file handling and API calls can continue seamlessly, thereby enhancing reliability in production environments.
Python Typing Adoption Trends
A collaborative survey conducted by JetBrains, Meta, and Microsoft highlighted the increasing adoption of types in Python development, with 88% of respondents using them regularly. The survey underscored that many developers find types helpful for IDE tooling and documentation, as they improve bug detection and code readability. Notably, 66% of personal project developers also utilize type hints, reflecting a broader acceptance of typing practices even outside of professional settings. However, challenges remain, such as complexity and unfamiliarity, indicating the need for improved education on type hints.
Streamlining Type Annotation with Write Typer
Write Typer is a new tool designed to facilitate the addition of type annotations to existing Python codebases, especially beneficial for projects that were initially untyped. By inspecting the data exchanged during tests, it automatically generates function signatures with appropriate type hints. This tool shows significant performance advantages over similar products, promising near-zero overhead when applied to complex applications. It simplifies the tedious process of retrofitting type hints into legacy code, thus enhancing code quality without requiring extensive manual intervention.
Enhancements in Python Script Distribution with UV
The introduction of UV has revolutionized self-installing Python scripts by enabling dependency management directly within the scripts. With a simple shebang, scripts can automatically install any required packages when executed, shifting away from the traditional need for manual installation. This feature allows developers to easily create and share Python utilities, effectively reducing setup barriers for users. By utilizing inline metadata to handle dependencies efficiently, UV streamlines the process of maintaining script functionality across different environments.
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.
DBOS Transact is a Python library providing ultra-lightweight durable execution.
Durable execution means your program is resilient to any failure.
If it is ever interrupted or crashes, all your workflows will automatically resume from the last completed step.
Under the hood, DBOS Transact works by storing your program's execution state (which workflows are currently executing and which steps they've completed) in a Postgres database.
88% of respondents “Always” or “Often” use Types in their Python code.
IDE tooling, documentation, and catching bugs are drivers for the high adoption of types in survey responses,
The usability of types and ability to express complex patterns still are challenges that leave some code unchecked.
Latency in tooling and lack of types in popular libraries are limiting the effectiveness of type checkers.
Inconsistency in type check implementations and poor discoverability of the documentation create friction in onboarding types into a project and seeking help when using the tools. “
Notes
Seems to be a different survey than the 2023 (current) dev survey. Diff time frame and results. July 29 - Oct 8, 2024
Creating your own ~/bin full of single-file command line scripts is common for *nix folks, still powerful but underutilized on Mac, and trickier but still useful on Windows.
Python has been difficult in the past to use for standalone scripts if you need dependencies, but that’s no longer the case with uv.
Trey walks through user scripts (*nix and Mac)
Using #! for scripts that don’thave dependencies
Using #! with uv run --script and /// script for dependencies
If you live in a place (or are in a place in your life) where these prices are too much, let me know. I had a recent request and I really appreciate it.