Cleaner async Python SDKs with constructor-based approach
Blog post from Speakeasy
Python SDK generation now supports a constructor-based approach to handle synchronous and asynchronous operations, providing a cleaner interface by eliminating method name duplication and confusion, which was caused by the previous method-based system with _async suffixes. This new approach differentiates between synchronous and asynchronous clients through separate constructors, making async usage an explicit choice and improving IDE suggestions by avoiding duplicate method names. Users configure this behavior in the `gen.yaml` file, with the `asyncMode` setting offering a 'split' value to enable the constructor-based approach, although this represents a breaking change for existing SDK users who will need to update their code. The change aligns with Python’s async ecosystem, which uses an event loop for non-blocking I/O operations, and matches patterns used in established Python libraries, offering a more intuitive interface for developers familiar with async conventions.