Today we’re excited to announce the v1.0 release of the Momento client for Python.
At Momento, simplicity is one of our north stars. We want the Momento experience to be simple and delightful for our users on both the server side and the client side. On the server side, this means you just create your cache and go, leaving all of the scaling and operations concerns to us. On the client side, this means having an SDK that makes it simple and intuitive to write bug-free code that interacts with your cache, and not having to spend a ton of your time thinking about tuning, thread-safety, or other esoteric concerns.
This week we put the finishing touches on our Python client, with special attention and testing to ensure that the APIs feel easy to integrate into your existing applications and libraries. Now we are excited to share the result of that hard work with you!
Sidenote: If you want to dive into the nitty gritty of how we think about designing, building, and tuning our SDKs, check out our Shockingly Simple blog series!
Python client library highlights
asyncio and traditional support
Our library features two CacheClient implementations: one asyncio and one traditional (blocking). asyncio, introduced in Python 3.4, allows you to turn network I/O bound applications into responsive ones without the fuss of multi-threading. This programming model fits hand in glove with Momento Serverless Cache. You can consume CacheClientAsync from your existing asyncio code without any concerns about blocking the event loop or bottlenecking your application. If your application is synchronous, no worries; we have a traditional CacheClient that does blocking calls for use in your synchronous code too.
Support for collection data types
The Python client also supports our new collection data types! Now, in addition to storing strings and byte arrays in your Momento cache, you can also store lists, dictionaries, and sets! The Python collections APIs give you flexibility as to what Python types you want to use to represent your results (dict, list, set etc.) for seamless integration into your existing code.
Discoverable response types for bug-free code
There are multiple types of responses you can get from an API call. For example, when you make a Get request to retrieve a value from your cache, the response might be a Hit, a Miss, or an Error. Depending on which of those you get back, there will be a very different set of properties that you need to access on the response (for example, a Hit will have an associated value that contains the data from your cache, but a Miss will not.) You can use Python’s instance of type guards to check which response type was received and a Python type checker can then infer the correct type to give you a strongly-typed response object for each of those cases. This means that you can easily discover all of the possible return types in your IDE, and get compile-time type checking to prevent bugs. It’s always more pleasant to find a bug at compile time than at run time! (Bonus: with newer versions of Python—3.10 and above—we highly recommend using structural pattern matching.)
Easy logging configuration
The Momento Python client integrates with the standard logging library, so logs from your Momento client will be routed to the same destinations as the rest of your logs.
Tuning a network client can be a lot of work and the best settings can differ pretty dramatically between environments. For example, the best settings to allow you to explore and debug from your laptop probably aren’t the same settings that you want in your low-latency production environment in the cloud. To help keep things simple, the Momento Python client comes with several pre-built configurations designed for different types of environments like these. The configuration is fully customizable if you have a unique need that we haven’t accounted for, but we did our best to make sure we would have the 90% case covered so that you don’t need to spend your engineering hours on tuning.
Easy to use in interactive environments
We believe the Momento Python client should be easy to use whether you are using an IDE or exploring in an interactive environment. To make this possible, the client library has rich documentation and full coverage for __str__ and __repr__. Try it out on the REPL or in a Jupyter notebook!
Take the Python client for a spin today
You can get started with the 1.0 version of the Momento Python client right now. If you haven’t created a free Momento cache yet, visit our getting started docs. You can try out the Momento CLI right from your browser, no software installation necessary! Or if you are ready to try it out on your own machine, check out the docs for getting started with the Python client on GitHub!
We hope you love it! And if you don’t, we’d love to hear about it so we can improve it further. File a GitHub issue or ping us at email@example.com.
Stay tuned for additional announcements about exciting new features. In the 1.0 version we support basic cache management operations, strings, bytes, and the new collection data types. We have plans for additional exciting features in subsequent releases—watch this space!