[UPDATE] safe-result 4.0: Better memory usage, chain operations, 100% test coverage

Posted by a_deneb@reddit | Python | View on Reddit | 39 comments

Hi Peeps,

The previous version introduced pattern matching and type guards.

Target Audience

Anybody.

Comparison

This new version takes everything one step further by reducing the Result class to a simple union type and employing __slots__ for reduced memory usage.

The automatic traceback capture has also been decoupled from Err and now works as a separate utility function.

Methods for transforming and chaining results were also added: map, map_async, and_then, and_then_async, and flatten.

I only ported from Rust's Result what I thought would make sense in the context of Python. Also, one of the main goals of this library has always been to be as lightweight as possible, while still providing all the necessary features to work safely and elegantly with errors.

As always, you can check the examples on the project's page.

Thank you again for your support and continuous feedback.