Coercing data into a normalized form
Project description
This library provides functions that coerce datastructures into normalized forms. For example, converting an arbitrary dict into a form that is suitable for passing to json.dumps.
The tornado framework has a function called recursive_unicode in the tornado.escape module. It is a very simple recursive walk of datastructure that switches on type and transforms string values into unicode strings. I use this in production software regularly and it works like a charm. Or at least it did until my software encountered a deeply nested dictionary and I received a RuntimeError: maximum recursion depth exceeded error in my service log. This is one of the exceptions that strikes fear into most engineers when it rears it’s head in production.
That is the primary reason for this library existing. It provides the same simple string encoding function iteratively instead of recursively. At the same time, the need to coerce values into a normalized string form is something that I’ve had to do repeatedly so it might as well be plopped into a reusable library.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for coercion-0.0.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b9a03324618f29a15d23cfa85fab1025e06653c61171cf63f3412bd097030595 |
|
MD5 | 0bb33256c1ce70f213178d327bc21fc5 |
|
BLAKE2b-256 | a171c6fed642192b6fe58c93845e4dfb2599868ff9b2890afb085e2de4ee76fe |