Brought to you by Talk Python Courses and Six Feet Up consulting

#505: Introducing diskcache-oxide

Published Tue, Nov 17, 2026, recorded Tue, Nov 17, 2026
0:00
00:39:33
Watch this episode on YouTube
Play on YouTube
Watch the live stream replay

About the show

Sponsored by LongLink: pythonbytes.fm/longlink

Connect with the hosts

Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesday at 7am PT. Older video versions available there too.

Finally, if you want an artisanal, hand-crafted digest of every week of the show notes in email form? Add your name and email to our friends of the show list, we'll never share it.

Michael #1: tinyjobs: a SQLite job queue goes free-threaded

tinyjobs is a Python job queue and cron scheduler that starts with a SQLite file and no dependencies. Switch the URL to Postgres or Redis without rewriting tasks. It runs async tasks natively, embeds workers in FastAPI, and plugs into Django 6's tasks framework. The creator's free-threading audit found four races hidden by the GIL.

  • Background jobs without deploying a broker, plus a concrete case study in what removing the GIL exposes.
  • The creator reports races in the task registry, codec cache, cross-thread flag and thread pool. hiredis can re-enable the GIL; the worker warns when it detects that.
  • On 3.14t, --loops N runs event loops in separate threads. The author's laptop benchmark hit 42,000 async jobs/s with eight loops and two Redis instances, close to eight processes. SQLite rejects loops above one.
  • Clock-skew lesson: two hosts 20 minutes apart duplicated 492 of 3,000 jobs on 0.7.0. Using Redis server time fixed that test, not the general exactly-once problem.
  • Author's SQLite measurements: about 572 jobs/s end-to-end; a 20,000-job burst drained in four seconds. Synthetic workloads and different harnesses, not interchangeable throughput claims.
  • At-least-once delivery still requires idempotent tasks. Python 3.12+; young project, with the README now listing v0.11.0 versus the email's v0.9.0. Docker setup:
services:
  web:
    build: .
    command: uvicorn main:api --host 0.0.0.0
    volumes: [jobs:/data]
  worker:
    build: .
    command: tinyjobs worker --app tasks:app --shutdown-timeout 25
    stop_grace_period: 40s
    volumes: [jobs:/data]
volumes:
  jobs:
    external: true

Calvin #2: funkycache: cache Python functions in SQLite

  • Alex Chan's functools.cache-style decorator stores results in SQLite, so they survive after the process exits. He built it to speed up his static site build.
  • It's released on PyPI: funkycache 1.0.4, from November 15. The first release, 1.0.0, came out November 7. It needs Python 3.14+ and depends on pydantic and xxhash.
  • Usage: cache = FunkyCache(storage="sqlite"), then @cache.register(files=[...], values=[...]). A cache entry is invalidated when the function's source file changes or when any listed file or value changes, such as a library version.
  • Return values go through Pydantic's TypeAdapter, based on the return type hint, so it only works on typed code.
  • Generators get special handling. functools.cache hands every caller the same generator object. funkycache saves the output as a list and gives each caller a fresh iterator, up to a soft memory limit.
  • Cache keys are JSON hashed with XXH64. They're deliberately lossy, and that's fine because nothing reads the original arguments back out of a key.
  • The design notes are a good segment on their own: the author had used MD5 because they "conflated weak with fast," and in their limited testing JSON was faster than pickle and easier to debug.
  • With a warm cache the site builds in about half a second, and the library is only a few hundred lines including tests. It doesn't watch files on purpose, to stay small.

Calvin #3: Ghostman - a keyboard-driven terminal API client

  • A local-first Postman alternative that runs in the terminal, with no cloud account required. It's MIT licensed and was featured in PyCoder's Weekly #760.
  • It's released on PyPI: pip install ghostman, then run ghostman. The current version is 0.1.8, from November 3. The first release, 0.1.0, came out October 31. It needs Python 3.10+.
  • It's built on Textual, httpx and Rich, so it's pure Python under the hood.
  • It sends GET, POST, PUT, DELETE and PATCH requests, shows DNS and time-to-first-byte timing live, and colors JSON responses automatically.
  • A built-in webhook inspector: Ctrl+W starts a listener on port 9090. Captured payloads show headers and timestamps, and you can load one straight into the request editor.
  • Collections are plain JSON/YAML files you can commit to Git. The README gives two different folders for them (.ghostman/ and ~/.ghostman/).
  • It's fully keyboard-driven: Ctrl+S sends, Ctrl+K saves, Ctrl+N starts a new request, Ctrl+Q quits.
  • The author claims about 30MB of RAM and a cold start of about 150ms; I haven't checked either number. It's a young project, with 158 stars and 15 commits.

Michael #4: diskcache-oxide: A shared, durable disk cache

Michael's diskcache-oxide is a Rust-backed, SQLite-based cache for Python workers sharing one directory on the same machine. Entries survive process restarts without running a cache server. It keeps the familiar diskcache API, adds fork and free-threading safety, and uses msgpack or JSON by default instead of pickle.

  • Michael's item: a shared cache for multi-worker apps without deploying Redis or keeping a separate dict warm in every process.
  • Cache, FanoutCache sharding and transactions are available now. NullCache switches caching off without changing call sites; Caches manages named caches for an app.
  • Author's bench/gate.py, Linux container on Apple Silicon, CPython 3.14, 99:1 reads/writes: about 750k ops/s with one thread and 723k with eight; diskcache 5.6.3 falls to 44k. Not independently tested here.
  • Free-threading support is explicit: the Rust extension declares gil_used = false. A process-wide fork barrier protects SQLite state when workers fork.
  • Pickle is opt-in. Tagged serialization preserves types such as tuples, sets, datetimes and Decimals, with registration for custom types.
  • The docs come to about 70,000 words, the length of a typical novel. Of that, about 53,000 are the written story (guide, recipes and the home page), and the rest is API reference, the agent skill and code samples.
  • Early release, not full diskcache parity: string keys only; AsyncCache, memoize, tags, Deque and Index are still planned. The network cache server is a roadmap item too.
  • Python 3.14+; macOS and Linux wheels include SQLite. Windows support is planned. Migration changes the import and uses a new directory, not the old cache.db.

Extras

Calvin:

  • Django Software Foundation Board Nominations open until December 2nd Michael:
  • Startpage paid plans
  • Test driving Helium Browser
  • Tallyman got a big update, give it another try
    • Tallyman is my command-line tool for seeing the shape of a codebase, with line counts grouped by language and categories such as Code, Docs, and Specs. Version 0.4.3 bundles new controls and a long list of fixes.
      • I made a bunch of massive updates this week. If you tried Tallyman before and it didn't work for your project, give it another try.
      • Use --no-save to try setup choices without writing a config, and --exclude PATTERN for one-run file exclusions.
      • Lots of fixes to gitignore handling, nested configs, the setup TUI, encodings, and image export. First runs in CI or pipes no longer hang waiting for setup.
      • Optional exclusion of inline Rust test code, plus MATLAB and Solidity support, bringing the language count to 44.
      • Want another feature? Submit an idea through a GitHub issue.
  • Bunny.net fonts disappoint.
    • Root cause: Bunny Fonts began serving its font files from cdn.jsdelivr.net, which our CSP blocks - production had silently fallen back to system fonts.
  • Talk Python Meetup: SQLite Might Actually Be All You Need

Jokes:

Episode Transcript

Collapse transcript

00:00 Hello and welcome to Python Bytes, where we deliver Python news and headlines directly to your earbuds.

00:05 This is episode 505, recorded on November 17th, 2026.

00:10 I'm Calvin Hendrix-Parker.

00:11 And I'm Michael Kennedy.

00:12 Happy to have you here.

00:13 This episode is sponsored by Longlink.

00:15 There'll be more about that in the break in between.

00:18 But if you want to connect with Michael and I online,

00:21 you can find us on Mastodon Bluesky X and LinkedIn.

00:24 And if you want to find the show, check us out on Mastodon Bluesky X.

00:27 Join us live if you want to experience this in real time at pythonbytes.fm/live.

00:33 You can be part of the audience.

00:34 Usually we're recording Tuesdays at 7 a.m., but another older versions of the videos are there as well.

00:39 And finally, if you want an artisanal handcrafted digest of each week's show notes in email form,

00:44 go and join our friends of the show list and we will send it over to you.

00:48 Michael done a good job of making that happen.

00:50 Speaking of making things happening, what about job cues?

00:54 I have such an interesting project to come up here.

00:58 So let's switch over.

00:59 Perfect.

01:00 Called Tiny Jobs.

01:02 So this one comes to us from Pier Giuseppe.

01:06 So Pier Giuseppe, this is his project, send it over.

01:08 And I'm going to have to just apologize in advance.

01:11 I am on a SQLite mission.

01:14 I'm a believer, Calvin.

01:16 And so this is amongst that, but it is.

01:19 I leaned into it.

01:20 I've also added a SQLite topic today too.

01:23 Incredible.

01:23 So people are just going to have to accept like a couple of weeks of SQLite

01:27 amazingness because it is, I honestly think it's really coming into its own.

01:31 What do you think?

01:32 It's always been there.

01:33 It's an interesting project, right?

01:34 It is.

01:35 You know, I think it's, I think the wall stuff, honestly,

01:37 the right ahead log has made the durability sort of much stronger and sort of brought it into like,

01:44 you can actually use it now, you know?

01:45 Anyway, like I said, this is only deposit one, I guess, on that story.

01:50 So maybe there'll be more.

01:51 I mean, I know there'll be more, but this is part one.

01:53 Anyway, Tiny Jobs.

01:54 So Tiny Jobs is built around fundamentally SQLite, though it can do Postgres and Redis.

02:00 And what it is, is a background job and cron system for Python.

02:04 So imagine I want background jobs like sending email or rebuilding search indexes or, you know,

02:12 updating Parquet files or parsing Parquet files and moving them into some kind of analytical database.

02:18 Kick off an agent to do something.

02:19 Yeah, that is definitely the 2026 version,

02:22 isn't it?

02:22 Yeah.

02:24 So you can do all of that with maybe no server or maybe a server,

02:28 depending on how you want to run it.

02:29 This one, it kind of is most likely you would run it as a local separate Docker container

02:35 as part of your thing.

02:36 So when you say Docker Compose up, like your app starts and this thing starts,

02:40 but you can run it in process on things that are async, like FastAPI and so on.

02:45 So how does it work?

02:46 Well, you just come down and create a tiny job thing.

02:52 You give it, by default, a SQLite file.

02:55 So your connection string is just a file path as it is.

02:59 And then you just put app.task or jobs.task, whatever you want to do,

03:04 onto functions.

03:05 Like the examples are generate PDF or transcode this video.

03:10 Given a video ID, you know it's going to go to the database,

03:13 pull it up, that sort of thing.

03:14 But it has sort of a tenacity, stamina sort of thing as well,

03:19 like five max attempts, timed out for, you know, 300 seconds,

03:23 right?

03:24 Because how long is your video?

03:25 I could tell you, you might want to up that if you're doing a lot of video work.

03:28 I've run those overnight.

03:30 But anyway, the point is there, you know?

03:32 It's really, really elegant.

03:34 I really like this.

03:35 I had not seen this before.

03:36 And now I'm like, how does this not escape my like purview?

03:39 It's amazing.

03:40 I know.

03:40 It's so good.

03:43 we've got you can give it a cron the task instead of just call it you give it a cron one of those

03:48 what do you call this cron like signature how about that yeah okay and you give it a time zone

03:53 and it just runs like you can say 30 space two place star star star and it just runs on its own

04:00 it has guaranteed operation like it'll guarantee that it will handle the jobs even though it's

04:06 sqlite does not guarantee they won't run twice if like for some reason you pull the power halfway

04:11 through, it might go, okay, that didn't finish.

04:13 I'm going to start over.

04:14 If you run it in process, then it will basically,

04:17 if something is running and it's running in process, it will hold back

04:21 the shutdown until it sort of drains its jobs, which depending on the kind of jobs you got,

04:26 it might be awesome. It might be not awesome.

04:28 If you're sending email, probably fine.

04:30 If you're transcoding a video, probably not fine.

04:33 You know what I mean?

04:34 So think about what you're doing, I'm guessing here.

04:36 Yeah, exactly.

04:38 It comes with a Django tasks backend for the Django, what is that, 6.1 when that came out?

04:43 Also, again, super elegant,

04:44 super cool.

04:45 This is a really, really nice.

04:46 Yeah, Django has this tasks thing, but it doesn't really have an implementation

04:50 that comes with it.

04:51 And so here's like, I don't want a server.

04:53 I just want a file.

04:54 You know what I mean?

04:55 I want a thing to manage.

04:56 Simplicity is the feature here.

04:58 Yeah, absolutely.

04:59 So a lot of cool stuff that you can do here.

05:01 And I had, this is really neat.

05:03 This is absolutely on the case.

05:05 So I've warned people about SQLite.

05:07 They also will have to be warned about free-threaded Python.

05:12 Lots of news.

05:13 Because these are things that are intersecting for me on stuff that I'm working on right now.

05:18 Part of my mission.

05:18 So anyway.

05:20 For listeners who don't know, Michael's on a terror to make free-threading available to the world.

05:26 That's my mission.

05:27 Yeah, like last week was Gilgard, right?

05:29 G-I-O, Gilgard.

05:30 This week I have something way bigger.

05:31 Anyway, so free-threaded Python.

05:34 I talked to Leppie and said, what's the story with free-threading?

05:37 I'm on this.

05:38 He's like, you know what?

05:39 You're right.

05:39 Let me make sure it works.

05:40 And so the gil stays off on Python 3.14t and dash loops and runs several event loops in one process.

05:50 I imagine because I have been juggling this very hard.

05:53 It is not easy.

05:55 Usually what I'm thinking is happening is each dedicated free-thread gets its own dedicated event loop.

06:02 And then because sharing them across threads, it's kind of,

06:05 I don't know, it's like Ghostbusters crossing the wires.

06:07 You probably shouldn't do it.

06:08 You might be able to.

06:10 The performance looks pretty awesome, too.

06:13 You've got some performance numbers here.

06:14 Yep.

06:15 Where did I put them?

06:16 Read them to us here.

06:17 Oh, here we go.

06:18 No, I got it.

06:18 10 hours of steady load on one SQLite file, almost 900,000 jobs.

06:25 Wow.

06:25 And this is sort of the durability test.

06:28 Like, let me see if I can hammer this and break it.

06:31 I have some other interests.

06:32 Like, I'm telling you, SQLite, y'all,

06:34 it's out of control.

06:35 It's off the hook.

06:36 It's something else.

06:37 So, yeah, 900,000 jobs in 10 hours.

06:41 Yeah.

06:41 Nothing lost.

06:42 That's amazing.

06:43 All right.

06:44 Really impressive.

06:45 No, that's super cool.

06:45 So I'm glad you pointed this one out to me.

06:48 Yeah.

06:48 Speaking of things being funky, some other cool stuff over here

06:52 on the SQLite front, too.

06:53 All right.

06:53 Let's keep the SQLite train going.

06:55 This is going to be straight SQLite, like right down the line.

06:57 Let's go.

06:58 Well, so you're familiar with with func cache or functools cache, correct?

07:03 So this is Alex Chan's decorator style that stores

07:08 results in, guess what,

07:09 SQLite. They survive process exits.

07:12 So basically, if you've got something

07:14 where you were using, say, func cache in the past or functools cached in the past, that would

07:19 disappear when your process stops and your memory goes away.

07:22 This allows it to survive those restarts.

07:25 One of the interesting use cases that they used in their example here was for static

07:31 site generation.

07:32 For static site generation, a lot of times most things don't change,

07:36 but you run the process once and then it's done and then now you run it again and it'll go through and redo most of

07:41 the operation.

07:42 With this, it can actually pull those resulting values out of SQLite and save you

07:48 tons and tons of time. So if you've got a large-ish static site,

07:53 this will save you a ton of time on generation it'll save you for example if you're using ci cd or GitHub actions this will reduce your

07:59 your GitHub actions run times so obviously saving potentially money or credits or whatever you're

08:04 using to go out there and build those pieces it works very very similarly to the cache stuff or

08:12 the functools cache where it's just a you can register the sqlite storage and then you use

08:18 decorators against the expensive functions, for example,

08:22 here, and then you can specify

08:24 how it gets hashed. So under the covers, it is hashing.

08:28 You can't, for example, you can't hash,

08:30 use a dictionary as a hash key.

08:32 You can use it as a value, but you can't store that as a key because

08:34 the dictionaries themselves are mutable.

08:36 They figured out how to optimize around turning that

08:39 dictionary into a string, which is an immutable object in Python, to allow that to be the key for

08:44 or the pulling back the value out of the cache.

08:47 That actually led to a cool discovery by them and me now,

08:51 which is JSON hashed as a string.

08:54 There's obviously different ways to do it.

08:55 And then if you want to hash it as the key, there's,

08:57 for example, you could just use an identity function

09:00 or an MD5 function, for example.

09:02 I had never heard of this hashing library called XXH64.

09:06 I don't know if you've run across that or not either.

09:08 No, that's new to me, yeah.

09:09 Yeah, so converting into JSON,

09:11 basically we're looking at options like pickle and JSON.

09:13 Obviously I mentioned JSON as one that got chosen,

09:15 but if you look here on the performance and time,

09:20 being able to store that into the database and then compute that hash obviously has a performance impact.

09:26 The HXXH64 insert and lookups, you can see here are very, very quick,

09:32 under almost 0.01 seconds in the benchmark compared to like MD5 being 0.1 seconds.

09:40 So we're looking at like a times 10 speed increase

09:43 on the MD5 version, which I've made this mistake in the past as well,

09:48 thinking like, well, MD5 is not necessarily secure,

09:50 so it must be fast.

09:51 Not true, not necessarily true.

09:53 So HH, or good Lord, I'm gonna get that right someday.

09:57 XXH64 is not cryptographically secure, but that's not the point here.

10:02 We're using it for identity.

10:03 And so we were looking for the fastest way to create some kind of a hash.

10:06 There's an opportunity, potential opportunity

10:08 for hash collisions, but in this scale-

10:09 That is so much faster.

10:11 I'm so interested in this.

10:12 Yeah, yeah, exactly.

10:14 If nothing else, if you don't even use the SQL-like funky cache piece of this,

10:18 discovering that there is a faster hashing mechanism

10:21 when security is not the important part of why you're using it,

10:26 this is well worth the discovery alone.

10:28 So yeah.

10:29 Let me throw one more thing on hashing that has caught me out because I was looking at it a lot

10:36 with stuff I'm about to talk about.

10:37 Python has a built-in hash function, right?

10:40 So why not just use that?

10:42 It's the built-in, yeah?

10:43 You don't even have to use MD5 or any of those things.

10:45 It is not.

10:47 If I hash something and then hash it again, I'll get the same answer.

10:52 But if I shut down the process and start it back up again

10:55 and hash it again, I get a different answer.

10:57 Oh, goodness.

10:57 So if you save it to a file and you ask, is it in that file?

11:02 It's not in the file anymore.

11:03 So stay away.

11:05 For this purpose, for giving an ID,

11:08 don't use the build to pick something, this looks like a good answer.

11:12 Xxh64 looks like a really good option for reliable hashes that are fast.

11:18 So yeah, that was super cool to discover that.

11:21 I think if there's any of that here, cache keys,

11:23 they're hashed with the JSON bit, they're deliberately lossy,

11:26 which is fine, because what happens is they go through

11:29 a couple different iterations on, so I want to jump ahead too quick there,

11:35 the hashing is, here it is, basically reducing them into a quick hash

11:40 so that speed was the feature, and then using Pydantic to convert these models

11:44 to data classes and Python objects, and then refactoring so that each function

11:48 only takes a minimal set of required data.

11:50 So this was just an optimization, optimization,

11:53 optimization, because we're all talking about cache and speed here.

11:55 The other interesting bit with this specific tool

11:58 is there's a bit of a dependency tracking here.

12:01 So if you, for example, or generating a static site generation,

12:05 you've got a main like index blog page, for example,

12:09 and you add a new blog post, you would want that main page to get regenerated,

12:13 but it didn't necessarily change as far as the code's concerned.

12:16 So you can specify that when these pages change

12:18 or when this pattern of pages change, regenerate this other potentially expensive page.

12:23 So it's a little bit like a kind of a graph that you can establish.

12:27 So you could do something with something like Airflow,

12:29 but that'd be a little heavy handed.

12:31 This includes that dependency tracking built in.

12:33 So you can say registering specific files to track those dependent changes.

12:37 So if things change in templates, for example, regenerate them.

12:42 And so it basically shows this kind of reactive aspirations

12:44 or reactive programming.

12:46 If you change input article one, then the list of articles two steps away

12:50 can also change in response to it.

12:53 So a nice pattern for basically a very minimal DAG situation.

12:58 So if you didn't want the full blown, Actually, it's kind of worked well with your previous topic

13:02 about scheduled tasks, combining the previous tiny,

13:08 tiny, tiny queue, what was that called?

13:10 Tiny jobs.

13:11 Tiny jobs.

13:12 If you combine tiny jobs with funky cache, you actually get a very lightweight,

13:16 SQLite based version of Airflow, it seems like to me.

13:20 I was, again, thought that was a good combo

13:22 to put together this week's episode.

13:24 Yeah, that's really cool.

13:25 And I love the names.

13:27 I love the names, they're fun.

13:29 They're very funky.

13:30 Very, very funky.

13:31 They definitely are funky.

13:32 All right.

13:32 Now, before we move on, let me tell you about our sponsor this week.

13:37 So Longlink.

13:38 Let's talk about Longlink.

13:40 Longlink is a really cool platform for building business software.

13:46 Saves you a lot of the stuff that you got to do otherwise.

13:48 All the plumbing, the foundational stuff.

13:50 All right.

13:50 So this episode is brought to you by Longlink, of course, a growing startup out of Switzerland.

13:56 How much of your company still runs on spreadsheets?

13:59 I don't know what the answer is.

14:00 Probably it's too much.

14:02 Probably too much, even in my own.

14:03 In all of ours, it's probably too much.

14:06 So for most businesses, it's a lot.

14:07 Approvals live in email threads, tracking lives in shared Excel files.

14:11 Off-the-shelf software rarely fits, so you've got to work around it.

14:14 So AI has actually changed that quite a bit.

14:16 And I'm seeing that with other companies that are working with it.

14:18 They're like, oh, here's our new internal app.

14:19 I'm like, oh, that looks familiar.

14:22 Or I could see the origin of where that might come from.

14:24 So custom business software is now cheap to build, but keeping it simple and affordable to maintain is not as easy.

14:31 So that's the problem that Longlink is solving.

14:34 You write your business apps in plain Python with familiar libraries

14:36 and standard development practices.

14:38 Longlink provides the platform underneath.

14:41 Authentication, permissions, deployment,

14:43 storage, routing, logging, all handled.

14:46 You focus on the business logic.

14:47 Purchase approvals, vendor onboarding, work orders,

14:50 and complaint tracking to start one process and then build the next

14:53 and sort of work back through these apps that need modernization.

14:57 So get started in one command, uvx long link in it.

15:00 Platform has a free tier, no credit card required.

15:02 The project is open source and in beta, and the team would love you to try it out and share your feedback.

15:06 And while you're there, they would also really appreciate a GitHub star.

15:09 So check it out at pythonbytes.fm/long link.

15:13 The link, no joke, is in your podcast player show notes.

15:15 Is it long?

15:17 Actually, ironically or surprisingly, it is not long.

15:20 How about that?

15:21 That's great.

15:21 Great to hear.

15:22 Yeah.

15:22 All right. Let's go back over to you.

15:25 What's next?

15:26 Yeah, so I can't resist a great set of tools

15:29 and this one is no exception.

15:31 I love local based tools, I love terminal based tools

15:35 and this one is both.

15:36 And so this is a fast keyboard driven TUI API client and webhook inspector

15:41 written in Python called Ghostman.

15:43 So if you check it out, the GitHub repository for it,

15:47 it is no cloud, no electron,

15:50 100% local first.

15:52 It hits all the marks for me.

15:54 It's also MIT licensed.

15:56 It just, again, looks like a really cool tool.

15:59 I've started playing with it a little bit in preparation for the show.

16:02 They mentioned installing it via pip from PyPI,

16:06 but I would recommend just uvx Ghostman.

16:08 If you just type uvx Ghostman into your terminal,

16:11 you will get a beautiful little looking terminal thing.

16:13 So for those of you who've used Postman or Bruno

16:18 or some of the other web GUI versions of API client

16:22 testing out and exploring various REST APIs, this is an option you can use just right there in your

16:29 terminal.

16:30 It just launched, first release was like Halloween,

16:34 and then this most recent release came out November 3rd at 1.0.1.8, built on Textual, HTTPX,

16:41 and Rich, so it's pure Python under the hood,

16:43 which also makes, you know, warms my heart when I hear that there are these pure Python tools still

16:48 out there.

16:49 You can do things like, you know, obviously the standard get post put,

16:52 delete, and patch requests.

16:54 It'll show DNS and time to first byte. So you get a little bit of performance

16:57 stuff going on in there.

16:58 And it will also color your JSON responses in response.

17:02 It's got a built in, the neat thing, it's got a built in webhook inspector.

17:07 So if you use the keyboard, there's a couple of keyboard shortcuts for it, which is also kind of nice,

17:11 big fan of keyboard shortcuts.

17:12 Control W will start the webhook listener on port 9090.

17:15 You can actually point your application to it if it's posting webhooks and inspect what comes out the other side without having to resort to

17:22 like netcat and some other stuff i i used to do that quite a bit i would just like open up a netcat

17:27 watch the text just flow in but here you can get it actually like syntax highlighted which was nice

17:32 uh the webhooks are the worst i mean they're really valuable but they're so hard to debug

17:37 hard to debug exactly hard to debug you can build collections just like you could in postmans and

17:42 you can put them it looks for them under a.ghostman folder inside the current directory or you can

17:48 have a global one at your home directory with a.ghostman version of it there.

17:53 Again fully keyboard driven it's very very lean.

17:56 The author claims 30 megabytes of RAM and a cold start of

18:00 about 150 milliseconds.

18:02 So we all love a fast tool like that.

18:04 Actually I've got a demo for you. I'll show you a quick little demo.

18:07 I can put up my screen again here share screen.

18:11 I'll go to my terminal.

18:12 Here we go.

18:13 So here is going to add it back to the stage. There we go.

18:16 This is what it looks like when it launches.

18:18 It's got a couple of examples built into here. So you can just like

18:22 load that up, choose what you want. And I'm using the mouse with it,

18:26 oddly enough.

18:27 It's a full rich, you know,

18:28 2E interface, which is kind of nice,

18:30 but you can create posts, public,

18:33 you know, it's got the GitHub example here for Octocat.

18:35 You can get the response.

18:36 Scrolling works as you would expect it, or you can go fully full blown keyboard shortcuts.

18:42 If I hit the webhook UI, you can see right there webhook listener started on 9090.

18:46 So now if I was supposed to post something into it,

18:48 it would show up over here in the in the UI.

18:51 Again, really, really cool local first.

18:53 You can see there's the collections piece there.

18:55 You can create a new collection, start in adding in payloads and webhooks and headers.

18:59 And it's basically Postman.

19:01 But for those of us who love the terminal, I found a new tool.

19:04 I love it.

19:05 This is very Calvin.

19:06 I love it.

19:07 it's so true yeah it looks textual it is yeah it's textual and httpx which again just beautiful

19:15 uh and this is running inside of my 3d accelerated terminal kitty which i am a huge fan of because

19:21 everyone needs a 3d accelerated terminal why would you not doing at least 240 frames a second on your

19:27 terminal you're doing a terminal i mean speed is the feature michael speed is the feature but on

19:33 you know that is a joke sort of but at the same time if you get if you get flickering and stuff

19:39 in your terminal then that's also not fun that's really that's annoying it's no good no good

19:44 it's no good all right something that i think is good i want to i want to talk about the next thing

19:49 this is the big thing for for me this week so i've been a big fan of disk cache and disk cache i even

19:55 did a podcast episode on talk python with vincent warmerdom and we both said should we cover this

20:03 It literally is possibly one of the best caching options bar none out there.

20:08 It is so, so good.

20:10 But the person who maintains it just ghosted the world, which is fine.

20:13 I'm not putting them on blast or nothing for that.

20:16 But it leaves a big gap, right?

20:18 And had a bunch of problems, a bunch of GitHub issues,

20:21 a bunch of unanswered pull requests.

20:22 And I thought, well, this is part of my mission, right?

20:24 Like I'm trying to make free.

20:27 My mission is I want a foundation I can build web apps in

20:30 that is safe and free-threaded Python.

20:32 And while you're at it, let's just see if we can make it fast.

20:34 Yeah.

20:35 So my big announcement is I rebuilt disk cache and something called disk cache oxide.

20:40 Calvin, can you guess what that might be written in?

20:43 Let me guess.

20:44 I'm sensing a trend here in your projects.

20:47 Yes.

20:47 Is it Rust?

20:48 It is a Rust core.

20:50 Love that.

20:51 With Python.

20:52 It's a Python only cache.

20:53 This is not a Rust library.

20:55 So introducing disk cache oxide, Python cache,

20:58 Rust engine, SQLite storage.

21:00 And this thing is an absolute monster.

21:03 I mean, it's out of control.

21:05 So this is powering Python by Spatafim right now and the courses and talk Python.

21:10 And it's actually been running all the web apps for maybe a week,

21:15 week and a half, something like that.

21:16 I didn't want to announce it and have some kind of issue.

21:18 I'm like, let's just live with it for a while, see how it's going.

21:22 And it's been flawless.

21:23 So let me just scroll down here and pull up some numbers.

21:27 on a single SQLite file with one thread, just straight gil python,

21:33 nothing fancy yet.

21:35 It does in a 99 to one read-write ratio.

21:39 So 99 reads, one write.

21:41 That's pretty cash standard.

21:42 There's also a graph for a thousand reads and one write.

21:44 It does 670,000 reads and writes a second.

21:51 A second, okay?

21:52 Michael, isn't it just good enough?

21:55 Do we need this?

21:57 yes we do because the previous one was also very impressive like i i do not take away my my um

22:03 positive comments about regular disc cache yeah but if and here remember the free thread mission

22:08 this is my mission what happens if i take that same awesome disc cache not mine the original

22:15 and i use it in a multi-threaded situation it goes from 400 000 requests a second to 19 000

22:20 woof it's 20 times slower if i try to use it in a free threaded way yeah broken as that

22:25 It's no good.

22:26 And it's just, it was built for a different time, right?

22:29 And I would be totally content if, I think the guy's name is Greg.

22:32 Greg behind it would like go, yeah, we're totally going to ramp this thing up.

22:36 But he got hired at OpenAI.

22:37 And then like the next day, like responses on GetUp.

22:40 Like there was just, maybe it's a corporate thing.

22:43 I don't know.

22:43 It's just like not allowed to even reply, but done.

22:46 So I went through and I said, I want to take a similar API,

22:49 not identical, but almost the same.

22:51 and I want to build this free-threaded, multi-threaded,

22:55 Rust-based version of this.

22:57 Yeah, and that's what we got.

22:58 It's super, super neat.

22:59 And it does a bunch of things that the regular disk cache does it.

23:04 And I think this is really one of them, going to be one of the really best

23:08 caching libraries for Python.

23:09 So here's how it works.

23:11 So you're ready to deploy onto Py0 now?

23:13 Yes, yeah, 100%.

23:15 So you give it just SQLite file and it can be durable or not.

23:19 So the serialization for disk cache and a lot of these caches, I think I saw it in the other one, is pickle.

23:25 That's just wrong to me.

23:26 Like it's a security violation.

23:28 You hear this a lot with hugging face and those types of things.

23:31 Like, hey, if we use pickle, somebody could insert a malicious script.

23:35 And then when you just load the file, it runs this Python and it's bad.

23:39 Plus it's just not durable.

23:40 Like if I change the name of a field and I rerun it, like I can't parse it anymore.

23:45 Well, that's broken.

23:45 You know, like I can't control it.

23:47 Nothing like that.

23:48 So this by default uses message pack, which is a super tight binary format for storing things.

23:53 And also has JSON as another built-in option.

23:57 And if you really want, you can say pickle, but try not to, you know?

23:59 Now why risk it?

24:00 Yeah, exactly.

24:01 Those things can execute.

24:03 Yeah, so you can come up with this cache.

24:04 You can say, if something goes wrong with the GC serialization,

24:07 just throw that away and just say it's a miss, right?

24:10 So instead of trying to deal with a bunch of errors, you're just like, look, if I can't deserialize it, it's a cache.

24:14 What else am I going to do besides just say it's not there?

24:17 Or you can let it throw exceptions and so on.

24:20 And then you just cache get item or bracket item and then set as expirations.

24:26 Now, a lot of these SQLite local caches,

24:29 it's up to you to kind of manage the files and make sure at some point in your app you call expire to get rid of the other ones

24:37 or you can set a limit of how many it can have.

24:39 You can say delete and delete those if it's too big and call them and so on.

24:43 This has a dedicated worker maintenance thread in Rust that's periodically going around and just cleaning up.

24:49 So it's a little more tidy.

24:51 You can even use it for job scheduling and cross-process coordination.

24:56 So you can say, like, I want to claim a job.

24:58 I'll add this job, give it my ID, and expire.

25:01 And either it's already in there, which means it's running,

25:04 or you've added it, which means, hey, you're starting this job.

25:07 And the fact that you expire the previous one is you just keep trying to add this job.

25:12 It does git added.

25:13 That means the previous one expired.

25:15 So it's time to do, I don't know, refresh feeds or whatever.

25:17 And because SQLite is cross-atomic and cross-process,

25:21 this basically is multiprocess coordination.

25:25 So if I have, say, Granian or GUnicorn or whatever with four workers,

25:29 they can use this to have one of the workers periodically run one of the jobs,

25:33 which is pretty neat.

25:33 There's a lot of documentation that I've put together.

25:37 And by a lot, I don't think you would, until you start reading,

25:41 you're like, why am I not making progress in the scroll bar?

25:44 There's, by way of comparison, The Great Gap Spee is 45,000 words of the book,

25:50 the novel.

25:50 This is 70,000 words of like, hey, I'm new to caching.

25:53 What do I do on this situation?

25:55 How do I, you know, how do I work with serialization?

25:58 How do I work with like groups of named caches?

26:01 Or there's like recipes for different common things you do with like coordinated workers,

26:06 right?

26:06 that thing I just talked about, or using it for rate limiting, or using it for work cues,

26:11 and so on. So this is a really fun project.

26:14 Let me see if I can find the free threading.

26:18 Let's see, I think I was trying just under performance,

26:20 because this is also gets interesting.

26:22 So if I want to do a get 0.9 microseconds, that is less than one one thousandths of a millisecond.

26:29 I want to do a set, it's only 0.018 milliseconds.

26:34 But if you come down here, and you look at free threading,

26:38 for four threads, it does 1.3 million operations,

26:42 reads and writes a second.

26:43 That's pretty incredible.

26:44 Yeah.

26:45 And this is SQLite.

26:46 Here we go.

26:46 We're modern now.

26:47 And I'll tell you what, this is not,

26:49 oh, yeah, it's in Rust,

26:50 so of course it's fast.

26:51 No, this is Python code doing 1.3 million reads and writes a second.

26:56 It is so, so cool.

26:59 What else can I say?

27:00 I guess it's super tested.

27:02 Like I said, it's been running all the websites for a while,

27:04 But also I've been having, I had to reboot my mini, which is why I was messing with my camera at the beginning of my mini pro because I've had it do so much work.

27:12 It was, it'll run like, Hey, I'm going to do a big change to the way,

27:16 like the work stealing cue or whatever sort of works.

27:19 And so let's, let's make that change.

27:21 But I also want to test that there's like no race conditions and deadlocks and leaks and so on.

27:25 So I'll run it for like 24 hours, 17 workers doing 150,000 requests a second each for a day.

27:34 And it'll have this chaos monkey in there, like killing off the processes periodically and like seeing what's going on.

27:40 And it's been taken.

27:41 I think I did about 1.5 trillion cash operations.

27:44 Probably destroyed my drive.

27:45 That is a big number.

27:48 It's 1,500 billion operations.

27:51 Yeah, I think people recognize how big those numbers are.

27:54 We throw them around these days.

27:55 That's a very big number.

27:56 One final thing, super interesting that this has that might be not obvious is this fan out cash.

28:03 So one of the, you know, you've like, oh, I got SQLite, I have this problem, like where there's like this write contention or whatever.

28:09 Yeah.

28:09 So what you can do is you can say, I want eight SQLite files,

28:13 and it's going to automatically, given the key, it's going to use the hash and like a way to figure out where that goes.

28:18 So you can shard.

28:19 Yeah, so you can shard into eight or more SQLite things using multi,

28:25 when you're doing multi-threading, then each independent thread could potentially choose a different shard, in which case those are independent SQLite operations.

28:33 So super, super cool.

28:35 Now I tried to run this.

28:36 Yeah, I tried to run this with the old one and it just crashed because it like leaked handles

28:41 or couldn't deal with it.

28:42 It's like, nope.

28:43 It was fine on one, but as soon as you started to do threading,

28:46 it's like, nope, there's too many crash.

28:47 I'm like, yeah, no, this one doesn't crash.

28:49 It totally takes it.

28:50 So there's a lot of interesting things.

28:52 I don't think, oh, do I have a graph here?

28:53 Yeah, again, there's a lot of ops you can do here.

28:57 This is very fun.

28:58 So I'm really, really proud of this library.

29:00 I think it's going to be super useful for people.

29:03 Check it out.

29:04 I'd love for you to try it.

29:05 Is this full drop-in for disk cache ready, or do people need to make some modifications?

29:11 No, it's full drop-in.

29:12 One thing that it doesn't do is it doesn't take your existing cache files.

29:17 So if you've got a cache that was hard to compute, it's because I disagree with the philosophy of how to store the files. I don't want them as pickles,

29:25 and there's other things as well. It actually creates a separate folder path that it goes down.

29:30 So in that sense, you'd have to rebuild the cache.

29:33 But other than that, it's like 99% identical.

29:36 The one thing that's not there yet is the Django cache,

29:39 which is coming, folks.

29:40 But give me a moment.

29:42 It's a lot of work.

29:43 It's taking me some time.

29:44 But I'm working on the Django cache and some other ideas.

29:47 I'm thinking that there's really interesting things, like large files,

29:50 kind of like almost an S3 type of thing, which you don't necessarily want to put in the database,

29:54 but kind of like an aside storage of files.

29:57 I'm going to put them in the cache, and when the thing expires in the cache,

29:59 it manages the files coming and going.

30:01 And I think those kinds of things would be really fun to do as well.

30:04 Yeah, and I see this like Mac and Linux.

30:07 What's the holdup on Windows?

30:08 No, it's on Windows.

30:09 It is on Windows.

30:10 Yeah, if my docs say that it's not on Windows,

30:12 it is.

30:13 It just takes, these wheels take a long time to build

30:16 because the wheels are profile-guided optimized wheels.

30:21 So what I have is I have a whole profiling, like a series of stuff that it runs through

30:24 and it'll first build them bare and then it builds them with prof to make sure the test fast then it will build them with profiling

30:31 on take the results of the profiling and then rebuild them optimized with like that information

30:36 yeah and just doing that on windows was harder it's not super hard it's just more the automation

30:41 of it um so no i it's if you pip uv pip install or pip install it you'll get the windows wheels now

30:48 as well it's very cool awesome michael like wow thanks like i can't wait to see what next week

30:52 brings uh what what oxide project are we going to get next week i just you know i mean this graph is

30:57 sort of this first graph that's right on the home page it just tells like why why do we need

31:01 this like because the python space is not it's just not ready for three free threading and people

31:06 have not put an effort into it and this project is abandoned effectively right much much like

31:13 chameleon is not abandoned but it's just like it's no one is putting the time and energy go like we

31:17 really need to push this forward and the adoption of free threaded python is not going to work if

31:22 is the graph everyone gets. It's just like from high numbers to just collapse if you

31:26 try to use it. Like, well, why would I do this? This is like way

31:28 more compute and it doesn't work.

31:30 Well, it can work.

31:31 It just doesn't work unless you specifically put some focus on

31:34 it, you know? Yeah.

31:35 You're doing a good public service here.

31:37 Thank you. Thank you.

31:38 All right.

31:39 Well, let's head over into extras and see.

31:42 I've got a couple extras for us.

31:44 And one of them is the Django Software Foundation board

31:49 nominations are open until December 2nd.

31:51 There are five of the seven board positions open for election this year.

31:56 Go sign up if you are interested in participating

31:58 in the governance of an amazing open source project.

32:02 Kaplan Moss, still involved in the project,

32:03 especially from a governance standpoint, has been helping out getting this all going.

32:07 And we wanna thank those who have spent the time

32:10 and effort on the last round.

32:11 So Jeff Triplett, Abigail Avogato, Paolo Melchua and Tom Carrick,

32:16 the time, dedication, and efforts they've spent.

32:18 So go join the Django Software Foundation board

32:21 and participate in what happens next for that.

32:25 The one last other extra I wanted to put in here

32:28 is for those of you who don't know, one of the more prolific maintainers of Python has passed,

32:35 Tim Peters, passed in July.

32:37 And I wanted to remind people, this is one of my favorite Easter eggs

32:41 in the whole language, is the fact the Zen of Python is inside of,

32:46 and that was authored by Tim.

32:47 And if you just go import this from a REPL or just do Python 3 minus C,

32:52 import this, you will be able to read one of the things

32:55 I refer to constantly, which is the Xenopython.

32:57 So we're obviously sad to see that light extinguish.

33:02 And he was a great contributor to the language itself too.

33:06 But Xenopython, what a great legacy in my mind.

33:09 And everyone should go do that.

33:11 I tell people to print it out, frame it, and put it on their wall in the bathroom

33:14 so they can read it every day when they're brushing their teeth.

33:17 Words to live by.

33:18 Yeah, the Xenopython is amazing.

33:20 and it's had a huge effect but honestly that's just a part right like it's just a small part i mean

33:25 it's one i cherish because i when i was when i would teach people python that's where i'd start

33:30 with that because there's so many great things there he's obviously contributed way bigger things

33:34 to the language itself well he will be missed thanks for for bringing that up on the show yeah

33:40 all right michael you got some extras i have some extras i will try to be quick because i have

33:44 Extras start page, the search engine has always been nice, but you know,

33:49 I actually wrote an article and complained about how like the whole front,

33:53 like everything above the fold is now ads, which I'm like, this is,

33:56 but you could also put your money where the mouth is and say like,

33:58 I'd rather support the world than have ads.

34:01 And so they opened up a paid $4 a month for their search tools with zero ads.

34:06 And you know what, to me, I thought that's, it's pretty neat. So

34:09 I don't know. I just thought I'd give that a quick shout out for them.

34:11 Also, have you noticed my browser is a little different. I don't know if you've... I haven't, but I'm very curious. I saw

34:16 this listed in the extra. I peeked at this one and I'm very curious. Look how tight and like how much

34:21 space I have on my screen, on my little like streaming screen.

34:24 True.

34:25 And I've gone through a bunch of different browsers recently and someone has just informed, which is usually my children,

34:30 that my most recent browser choice is still problematic.

34:33 You know what? I mean, yes, but like

34:36 so is Firefox and some of its origins.

34:38 So like... Right.

34:40 There was somebody that wrote a parser that was a jerk.

34:43 And so, I mean, yes,

34:45 but at the same time, right.

34:47 But I'm sorry, using helium, which I've talked about before. And it's actually Python plus Chrome,

34:52 which is an interesting angle.

34:53 Like all of those sort of interactions is like, I believe Python and stuff, at least it was when

34:57 we talked.

34:58 So this is really neat.

34:59 It's privacy first, like brave.

35:01 and it has vertical tabs on the left, or you can have this super condensed view. And this is like, at first, when I saw this,

35:06 I like, Oh, this would be great for streaming, but it's so hard to navigate.

35:09 I can just hit like a button and then just i get a little drop down which is like vertical tabs but it's not you can

35:15 do auto hide there's even less than this calvin a hotkey to hide and close the vertical tabs on

35:19 the side oh okay i'm sold yes i know i know that was your whole thing i am moving over today now

35:24 it's it's still a pretty new project so you know take that with a grain of salt and like all the

35:28 things that you should consider but it is people who know me know i'm an early adopter i know exactly

35:34 Well, welcome to the show.

35:35 You fit perfectly in, right?

35:37 That's what this is about.

35:38 So, but it is based on Chrome and they promise to release Chrome updates frequently

35:44 and if there's any kind of issue.

35:45 So keep that in mind, but I'm enjoying it.

35:47 All right, Tallyman, my little app

35:50 that lets you get graphs of like how much, what type of code you're using in your project

35:58 and generate little shareable graphics that you can put images and so on.

36:03 Got a major release.

36:04 So I went through it and did a whole bunch of changes.

36:06 So if you're using that, give it an update.

36:09 I want to just call out in a not positive way, bunny.net,

36:13 which I love bunny.net for their CDN and their DNS and stuff.

36:16 But I had the crappiest experience with them.

36:18 So they have fonts.bunny.net, which is an alternative,

36:21 an API compatible alternative to Google Fonts.

36:24 That's cool.

36:24 Privacy focused, cool.

36:26 You know what's not cool?

36:27 Is if you build your website with it four years ago and you set a CSP policy

36:31 so people can't run crap on your website.

36:34 Like, hey, security, that is a thing,

36:35 right?

36:36 It is definitely a thing.

36:37 Well, they just decided we're going to not run that anymore.

36:39 And so we're just serving everything out of JS Deliver,

36:41 which is no hurt on JS, no shade on JS Deliver.

36:45 But I was at the, go ahead.

36:47 Yeah, but no one loves a brown bag release.

36:49 Yeah.

36:50 So I was at the Apple store with my daughter helping us

36:53 get something set up.

36:54 And the iPhone Duo was at it.

36:56 Oh, cool.

36:57 Let me see what the website looks on that.

36:59 And I load it.

37:00 I'm like, that looks amazing.

37:01 I click one thing, it says too many requests. I'm like, what?

37:04 Because the CSP policy didn't allow any of the fonts or any of the other things that needed. And so every page load was sending 1,600

37:11 CSP violations to my server. I'm like, oh my God, dude.

37:15 And it stopped serving all the fonts. I'm like, that is not a cool thing to do.

37:18 So if you, long story short, the extra is if you use bunny.net

37:22 fonts and you have a CSP policy, you need to review this.

37:25 All right.

37:25 Really quick. Last thing.

37:26 Did I say I'm on a kick?

37:28 I'm doing a members only Talk Python tech meetup. So please join the members,

37:34 come see the tech meetup or watch it after.

37:36 SQLite might actually be all you need.

37:38 So this, this is not even on any of the SQLite stuff I've talked about.

37:42 This is a totally different and even crazier SQLite story.

37:46 And it's going to be amazing December 2nd.

37:48 So it's in the show notes.

37:50 Hopefully you can be there. I thought attention was all I needed.

37:52 It is, but then attention helps you get

37:54 sequel light perfect um you know hat tip to the um transformers original paper yeah that's not

38:01 funny but you know what is what is funny two jokes some jokes you got two jokes yes i got two jokes

38:06 i've not peaked good i couldn't even decide i couldn't even decide something they're both going

38:09 in because what happened this week maybe last week this week i think it was last week all the things

38:15 happened last week has anyone tried to like i don't know check their outlook mail i'm kind of scared

38:21 about the next friday the 13th this last friday the 13th was pretty bad yes i know i'm i am not

38:27 a fan of friday 13th let's don't go down that path so remember clippy yes yeah the little thing says

38:33 um the joke says decommissioned just means the one machine in the building nobody will

38:38 ever dare touch it's clippy pops up and says would you like to try powering up the decommissioned

38:44 exchange 2010 server that you never bothered to remove from the rack so that you can get your mail

38:50 back this bit me this weekend i powered i powered off a piece of hardware i had in my little home

38:57 rack that i'd forgotten about for like the last year that i thought i'd taken out of service

39:01 sure enough stuff stopped working on the network things were talking to it yep it's they're in

39:05 there you don't know very real the other one also outlook based it has a picture of like earth rise

39:12 from the moon right yeah and it says the prophecy has been fulfilled i have two versions of outlook

39:18 neither of them is working it has been foretold so are we all it's all behind us now done yeah

39:25 we're good to go it's all fine we've got what's done what's done is done it's done i think this

39:29 episode's done what do you think i think so too thank you michael to you all next week


Want to go deeper? Check our courses




Subscribe to Python Bytes