canteen's blog

Python tree shaking

scene

You're thinking of writing a library you want to use for all of your python projects. It does a couple of simple things, most of which use validated model-based file loading (i.e. config files and API interaction).

simple cases

In the simple case, you're going to be using it for some config files.

Serialising / deserialising is easy, but you like some formalisation. So you use pydantic. Why not? It works well, it's fast, it's a good time. A little added sugar and crime and you've got serialisation to toml as well.

now what

This seems pretty heavy. Where do you go from here? That's a chunky tree to include in everything you write from here on out (including little shell scripts!).

Well I found this super dope tree-shaking project! Im definitely giving this a try, this is a great idea. I think it is the most promising candidate in this space I've found until now - the others are very conservative and so result in basically no profit.

I linked the readme in Chinese because the English one is very barebones. But using Firefox translate works fine, so whatever you've got probably will too.

#code #computer