Posts tagged: python

All posts with the tag "python"

275 posts latest post 2026-03-31
Publishing rhythm
Feb 2026 | 1 posts

I’ve been playing with 3d printing some items through the slant3d api. I’ve been pricing out different prints by running a slice request through their api.

I’ve been using uv for project management. It’s been working well for quick projects like this while making it reproducible, I’m still all in on hatch for libraries.

mkdir slantproject cd slantproject uv init uv venv . ./.venv/bin/activate uv add httpx rich python-dotenv

Get an api key #

You will need an api key from the slant api, which currently requires a google account and a credit card to create.

# .env # replace with your api key from https://api-fe-two.vercel.app/ SLANT_API_KEY=sl-**

slicing an stl with teh slant api #

Then you can run the python script to price out your print. I’m not exactly sure how this compares to an order, especially when you add in different materials.

SQLModel models ship with an is_, and is_not that you can use to compare to None without pesky linters complaining.

This comment summed it up quite well.

I believe this is concerned entirely with SQLAlchemy, not with SQLModel, and has to do with the required semantics to construct a BinaryExpression object. Hero.age == None evaluates to a BinaryExpression object which is eventually used to construct the SQL query that the SQLAlchemy engine issues to your DBMS. Hero.age is None evaluates to False immediately, and not a BinaryExpression, which short-circuits the query no matter the value of age in a row. From a cursory search, it does not seem that the is operator can be overridden in Python. This could help explain why the only possibility is by using the == operator, which can be overridden.

so rather than using Team.heros == None we can use Team.seros.is_(None) which checks for itentity not equality.

uv now can install python for you. uv is inspired by rust’s cargo, an all in one fast package and installation manager. uv is so fast and becoming feature complete, it’s really changing the python packaging ecosystem.

markdown it py running in rust claims to be 20x faster. I’ll definitely look into this if markdown it py is ever a bottleneck in my performance. At first glance it appears that plugins are written in rust not python, and there is no admonition plugin, so I’ll keep my eye on it for now, but I can’t use it.

diskcache has a peekitem method that allows you to lookup the expire_time of a cached item without changing it. I recently used this to implement debounce for fastapi background tasks with multiple workers running. since all the workers I care about are on the same machine, but running in different processes diskcache was a great option. All workers have access to the same disk, but not the same variables in memory.

I’ve been using fastapi more and more lately and one feature I just started using is background tasks [[ thoughts-333 ]].

I am using it for longer running tasks and I don’t want to give users the ability to spam these long running tasks with many duplicates running at the same time. And each fastapi worker will be running in a different process so I cannot keep track of work in memory, I have to do it in a distributed fashion. Since they are all running on the same machine with access to the same disk, diskcache is a good choice

My brain first went to thinking I needed another service like redis running alongside fastapi for this, then it hit me that I can use diskcache.

Here is how I used diskcache to debounce taking screenshots for a unique shot every 60 seconds.

Great listen for anyone interested in productionizing python code with docker. Itamar brings up some

Don’t trust base images for security, upgrade your packages. Vulnerabilties become published and solved giving the bad guys istructions how to wreck your day and these fixes wont come to your docker application for up to two weeks due to image build tatency.

For job based containers pre-compile your pyc for faster startup.

Alpine linux is probably not what you want for python. Many packages such as postgres ship pre-copiled binaries that work for most linux distributions wich use glibc, but alpine uses musl so the binaries will be incompatable requiring you to need to install a bunch of build dependencies.

I hit an issue with markata where even though a bunch of articles were cached, the site build was still slow because I was hitting hashlib.sha256 so hard for cache keys. I was shocked when this popped up in my profiler as a significant portion of the time spent. I swapped out for xxhash and that issue completely went away.

I just implemented a latest blog post link in Markata by asking for the first post slug from the blog feed. The implementation uses the jinja_md plugin to render jinja against the markdown and a tag to redirect.

My latest blog post is [[ {{ markata.feeds.blog.posts[0].slug }} ]]. Click the link if you are not automatically redirected. <meta http-equiv="Refresh" content="0; url='/{{ markata.feeds.blog.posts[0].slug }}'" />

Setting up the feed #

Feeds are setup in markata.toml configuration. They provide a handy way to create an html feed, rss feed, and quickly reference a filtered set of posts like this.

# you will need to enable the jinja_md plugin along with the defaults [markata] hooks = [ "markata.plugins.jinja_md", "default", ] # set up the blog feed [[markata.feeds]] slug = 'blog'...

sick wikilink hover

Today I set up some sick wikilink hover effects using tailwind see A Case For Tailwindcss. When you hover over them they show an image preview of the link that you are going to. I cant find where I have seen this but it comes from some docs sites.

I’ll finish this article later, just excited to see it up.

1 min read

markata

This post is a work in progress.

Markata is the static site generator that I created to build my website about this site. I built it for me and I enjoy using it. I know everying it can do and I can extend it to do more easily. I have set it up for some friends to also use it and am proud that it helps them publish their content.

It’s a meme to create your own static site generator to make your website. Yes its funny, I don’t recommend it if your not ready for the level of work that comes with it, but at the end of the day it’s very...

...