- Podcasts
- Python Bytes
- #489 Or JSON?
About this episodeTopics covered in this episode: django-orjson Best Django Redis configuration for speed and size Linus Torvalds puts the foot down against…
- django-orjson
- Best Django Redis configuration for speed and size
- Linus Torvalds puts the foot down against Anti-AI Kernel Maintainers
- Django Steering Council backs the Triptych Project
- Extras
- Joke
Transcript
From the publisherThis transcript comes from the podcast’s own feed, shown as the publisher wrote it.
#489 Or JSON?
Hello and welcome to Python Bytes, where we deliver Python news and headlines directly to your earbuds. This is episode 489, recorded July 21st, 2026. I'm Calvin Hendryx-Parker. And I'm Michael Kennedy. Hey, Michael. Welcome. Good to see you. We want to make sure you all recognize our sponsorships of the show. So thanks to Michael and the courses over at Talk Python. Go check those out if you head over. And he's got tons of new stuff he's been adding in there. And I hear there's more on the way. and then check out the fine folks over at Six Feet Up. So I'm co-founder and CTO of Six Feet Up and we do some amazing consulting to solve hard problems. We love using Python. I've been doing this for 27 years as part of that agency and I love it. If you wanna connect with Michael and I between the shows, you can find us on all the socials. We're on Mastodon, Bluesky, X, LinkedIn. And then the show has also got links in the show notes for the shows, Mastodon, Bluesky, and X. If you want to watch live, you can always catch us generally Tuesday mornings by time, very early mornings for Michael's time. So 7 a.m. Pacific on pythonbytes.fm/live to be part of the audience. Sometimes we'll get questions in there and we'll pop them onto the show and you can get them answered right away. Kind of real time feedback to the episode. Older versions are also available there if you want to watch the live stream and see our shiny faces as we go through and talk about the news of the day. Speaking of the news, Michael, I think you're going to kick it off with the first article today.
What a cool little thing. I've been getting more and more done with it. One of the things I did over the weekend was I've set up an automation such that Hermes can use the website to manage the YouTube channel. And then I set up a nightly job. So every night, as much credits as I can get for API interactions from YouTube, it will automatically go back and update the back catalog like 10 or 20 shows at a time.
Yeah, exactly. Like it's just everybody gets, you know, links and stuff in there in the videos if they watch it. And how do you get it? Well, is it a JSON API or something else? We don't know. So I want to talk about Django or JSON. Is it ORJSON or ORJSON? It's probably ORJSON. Hi, OR is my guess. Let's go with OR. I agree because ORJSON is weird. ORJSON? OR? ORJSON. ORJSON? I don't know. Yeah. So I want to talk about this project from Adam Johnson. So we have a couple of Django topics. This one is a Django topic, but it also goes more broadly. So there's kind of a multi-level thing going on here. Not the marketing badness, but just multiple uses. So this is a project that Adam created so that you can change Django's response model. So apparently the way Django uses JSON or generates JSON responses happens in a bunch of different ways. So it says there's a library called ORJSON. And somewhere it says, yeah, here we go. It says, compared to Python's built-in JSON, it boasts 10x faster serialization and two times faster deserialization. And I believe it is a little bit more forgiving of date times and stuff. It has like default conversions, whereas if you've ever tried to serialize certain things, it's like, nope. Sounds like a win. I know it does. Like I couldn't possibly figure out a way to represent time. What a weird, this is a rare concept we don't normally encounter. So this handles some of those things as well. So there are a couple of reasons that you might play with it, but it is a little bit different. So be a bit careful. So, all right. So the idea is that there's a bunch of different places, like such a great library, but adopting it isn't easy when your framework uses JSON in multiple different parts, in different places. So Adam introduces Django ORJSON, which provides a bunch of replacements and you just plug it in, right? So import JSON response and you can return that directly, which is cool. There's test capabilities loaded up in a template and so on. After seeing the initial proposal, Django ORJSON, Paulo, who was recently on Talk Python to talk about maintainer burden and AI, coming back to that at the end as well, or later, decided to push for the addition of ORJSON support in Django itself under a new feature called pluggable JSON serialization backend, which I think is pretty cool. I'm all for it. Yeah, it's nice, right? Like, why not make that an option?
Yes. And so I'm like, well, let me just try this. And one of the things that's really cool is with Claude Code and other things, you can say, here is a proposal for how to do this for JSON. How would I do this for Flask and Cort, where I'm running my apps? And can you tell me the areas where it might be a benefit or not so much a benefit? Not only did I get a little summary for how that might go, it's like, and I set up some test performance runs, and it turns out that you get four times performance boost, not 10 times performance boost.
of that analysis into the show notes and it turns out that if you have large json documents with a few fields then it doesn't give you a big boost if you have a very fine-grained json document with lots of small fields apparently that's where this performance starts to pay off and i happen to have like big chunky JSON, I guess is what I got. I don't know. It's got things like 100K of transcripts in a response, you know, not, and it's structured as a giant piece of text. It's not necessarily like subtitle text second and so on. So that's interesting. And it said, look, it could help your MCP server, but the traffic on the MCP server is not that high. You swap it out, you'd probably save 0.119 milliseconds of requests. And for a response that takes 1.1 milliseconds, you really wouldn't mess with it? I decided no, which I thought was kind of interesting in the first place. Like, you try it out, you're like, oh, cool idea. Just not for my use case. Most of my stuff is RSS. It's HTML. It's like not that much JSON. But I do think for the right use case, it would be really powerful.
Yeah, very cool. Well, mine's also performance related and I think it'll dovetail nicely into what you just mentioned here. Speaking of performance and JSON and evaluations, I think one of the things that has been nice about using these AI agents, like you just mentioned, you can put it on a mission to go try some hypotheses and some theories and etc. This is a article from Peter Mengson who revits a one from 2017. So this is actually the original performance article he did around fastest Redis configurations for Django. So a lot of folks just use the default out of the box configuration for Redis, kind of a standard thing these days to use for any kind of caching that you might use inside of your application, but it has tunable capabilities since you can adjust the format of the serializer. So whether it uses like JSON, UJSON, MessagePack, or Pickle, you can also adjust the compressors it may use. So whether it's using Zlib, LZMA, or ZStandard is a new one that's coming up. It didn't exist when he did this 2017. So he just, actually, this is kind of all pre-AI as well. He did it the old school hard way, which is specify a bunch of different configuration combinations, run through a framework and try and test and see what the performance boost may be based on the kind of data he threw at it. So if you look down here, actually it's kind of fun, very ASCII art result graphs here. I'm here for the ASCII art. I'm here for it. Yeah, I know. So JSON is the slowest. Here are the shorter or better, so best averages, like for averages, medians, and size of data stored. You can see here, JSON, not so great. Actually, I wonder if in his updated version, he did not use ORJSON. I wonder how that would affect this. But basically, MessagePack as a message format is going to be one of the fastest ones he found for this specific application. And then if we look over here.
Probably still. So I bet that sets a lower bound. Yeah. So updating here to look at three specific compressors, Zlibs, LZMA, and Zstandard, the LZMA is still slow. While it compresses well, it's slower from a performance standpoint. The default, actually not doing too bad here, except for size of data stored, which if you're saving larger sized items, there was a different performance difference, which actually I think leads to why coding agents like Claude Code and Pi and these orchestrators allow you to do this kind of experimentation with very low risk and overhead. Because ultimately, the end difference matters on the kind of data, like you just mentioned, the kind of data you're storing in these various serializers are going to determine a lot of the performance characteristics. So I hate saying it depends, but your mileage will vary based on what you're throwing into Redis and how you're accessing it. So it's always nice to be able to set up some kind of performance harness or benchmark where you can actually test these yourself and see how you get the most mileage out of these tools. And based on what I saw here, it seems like there's quite a bit of room for improvement for eking out more performance. So as we typically do, I like starting off with the defaults first and only optimize when I see a problem. But these are great ways to take a look at the different message format serializers for Django Redis and then the various compression formats that are out there for it so a nice methodology a nice little write-up showing some of the results and showing that it's actually not too not too hard for you to go implement this yourself a great way to get some squeeze more performance out of Django with your redis which
is already fast but here you can i love it yeah yeah it's super fast i 100 endorse here let's try it with the built-in stuff and then see because yeah like in my example i could have taken on one more dependency and thing i have to update but it's like do you really need a tenth of a millisecond No, it makes zero difference to me, honestly.
I know. Okay. So Linus says, I'm not having it, that there are people saying we're unwilling to use AI in any way against the Linux kernel. And it's pretty interesting. I'm going to link to the actual original thing here. I got some quotes that I pulled out. So this all has to do with this thing called Shashanko. And what Shashanko is, I don't work on the Linux kernel, so it's not a thing I'm super familiar with, just to be clear. But Shashanko is an AI PR review tool. I guess it's built into GitHub or something like that for automation. You know, like GitHub actions are the equivalent thereof. And it will review inbound PRs for bugs, for correctness, performance, that kind of stuff.
And I think there are some people that are like, no, heck no, I want nothing to do with this thing. So it's not necessarily just cutting AI completely loose and saying, hey, here's the spec of the kernel. Right. Make it better. See you next week. You know, it's way more subtle and less intense.
It's making us better at what we do. Exactly. So I'll just pull out a couple of pieces here. I think this is, this is a little noteworthy. My understanding is he was fairly against this kind of stuff and then kind of played with it more. It's like, you know what, actually I'm not against it anymore. And let me just put this out there. Like he acknowledges it. I acknowledge it. I'm sure a lot of people will that there are downsides to AI in lots of ways, but there are also upsides. Right. And so says Linux is not one of those anti AI projects, you know, think Zig or something like that. Right. And if somebody has issues with that, they can do the open source thing and fork it or just walk away. It's like, you know what? Okay. I mean, what do you expect from him, right? That's true. What do you expect? AI is a tool, just like other tools we use, and it's clearly a useful one. And it may not have been that clearly even just a year ago, but that's no longer the question. I think that's an important thing, right? Like people have formed opinions, especially people who have formed the opinions like, I don't want to touch this. This is junk. It's like, why would you come back to a thing that's junk? You know what I mean?
I do want to point out that there's this really good, I've mentioned this guy before on the show. Are you familiar with this? I am not. Maximilian Schwarzmüller, this German guy. He's really good at talking about trends in software development. And one of the things he says here is he, in response to talking about this, said it is time to wake up for some. So he put it less, more bluntly saying, look, if in a couple of years, if you're doing professional software development, you're going to have to be using these tools.
And you need to get good at them regardless of how you feel about them. You know what I mean? It's fine for hobby stuff not to do it. That's like a 12 minute. That's a summary of a 12 minute video, but it's really well done. So I recommend people check it out. And he's just an interesting guy. Okay, back to what Linus is saying. Yes, it can be somewhat painful tool for maintainer workloads and so on. And also because it just keeps finding embarrassing bugs, which is annoying, but amazing. I think that this embarrassing bugs bit is actually transient. We've got 10, 20, you know, however long the projects have been around for, years of tech debt. Tons. Yeah, and we send this tool on. It's like running a linter. Like, do you guys have a linter? No. Oh, you should try a black or rough or something. And then it's like, there's 2000 errors. we can't fix 2000 errors. Like we just don't run it anymore. You know what I mean? But projects that start adopting linters don't always have 2000 warnings or issues, right? All right, carrying on.
Yeah, 100%. It's just, it's kind of painful to deal with some of the fixes, but you know, you get through them and then it's pretty straightforward, especially with --fix and a lot of the modern ones. Okay. So the solution here says Linus is not to put your head in the sand and sing la la la can't hear you at the top of your voice it's to make sure the lm tools help maintainers instead of causing them pain we're not for and here's the essence of this whole um thing we're not forcing anyone to use it but i will verily loudly ignore people who try to argue against other people using it there's no ai is not perfect but but blankety blank anyone who points the problems points to the problems that ai had better be looking in the mirror and pointing themselves at the same time because people make
never AI camp are not using it even for completion do they never use it and I mean I held out on IDEs for a long time because I didn't feel like I needed the autocomplete but like that those days are long gone like this things have gotten so fast and have helped me like streamline my workflow where it's not standing in my way and I feel like these tools will get into that point where it is just like wrapping a amazing exoskeleton around your capabilities and going for it and doing more
and better. Yeah. Yeah. I don't remember the numbers. I don't know. I don't believe they're in here, but they might be in a fall. I mean, there's a conversation to be had. You can see, if you look at the art, the thread, but I believe it's something like this Shashanko thing is like 15% false positives, but 85% like, yeah, these are actual bugs that you didn't have to find.
Yeah, pretty good. Plus you're still expected to operate as a human in this case, like bringing the creativity, bringing the original thought, just letting it take care of all the mundane, boring stuff. Like making sure you cross your T's and dotted your I's in the code. Seems like all went. All went to me. 100%.
Yeah, so our third Django-related news item for the day is that the Django Steering Council is backing the Triptych Project. So if you're not familiar with the Triptych Project, it is three proposals for the HTML standard to make things a little more native and expressive. So adding in, for example, put patch and delete methods to forms. We've all abused post far too long and added in things like slash delete to the end of our API URLs to accomplish things that really should just be using a specific vocabulary or verb from HTTP language, which is delete. So this gives us the ability to put those three extra actions. The fact that button actions should be a thing. So buttons that just can fire HTTP requests without wrapping them in a form. How many times have you had a singleton button with form on top, form on the bottom? Or worse, like for example, if you're not using a button, but dressing up a link to look like a button, for example, like a logout, the logout button could potentially get triggered by some of the prefetch operations that are happening by some of the browsers or unfurling, et cetera. So you may get unexpectedly log out or unexpectedly delete something. Be careful when you make a button that says delete, that is actually a link. Those buttons should be buttons.
There was actually back in internet lore, there was a really interesting thing. I think at the early days of Wikipedia, that one of the delete buttons was actually just an Ahrefs that went to a delete operator, but did a Git and got indexed and deleted a bunch of Wikipedia. I think it was Wikipedia.
idea. Yep. So the idea is, yeah, let's, let's resimplify, make things more semantically operational in the way that we should expect them to work. The last thing, the last proposal is actually around partial page replacements. So if you are taking the ideas from basically HTMX, Unpoly, and Turbo, and putting them into the HTML standard itself. So this means if the standard gets adopted and the browser start putting this into their HTML parser and engine that's powering your web browser, less JavaScript and libraries can actually be shipped to get the same level of interactivity on the pages that we're doing right now today with things like HTMX. I really like the HTMX library. I feel like it gives people a clean, clear way to do things in Django really fast and have like a single page web app like front end without having to rebuild all of your Django models in React on the front end. Like with a lot of the React patterns, you are building the same models twice, the same routers twice, the same application basically has to be built and maintained in two separate frameworks. Where if you just had these capabilities built right into HTMX or the browser, I mean, with this triptych project proposals for the HTML spec, well, think about how clean and this is simple that the development could be, especially for testing out and running quick little one-off projects. They could be so much less dependencies, hopefully less maintenance going on in there. So I think that's really nice. The piece is relevant for Django. Django is here to help shepherd in the better web and new technologies for it. So that's why they're backing the Triptych project specifically. But also, for example, the Django 6 introduced template parcels, which are inspired by these patterns. So Django is kind of already ready to have this work. So if you're using HTML, you get some benefit that Django helps you generate these partials right out of the box, which is another one of the nice things about Django. It's kind of that batteries included, all the things just work. If you want to help, there's links here to the Triptych project, which if you are familiar with the web hypertext community, the what we G, I don't know how you pronounce that specifically, But this is basically taken over from the W3C for the HTML standards. And so they have submitted a proposal to this working group, which is basically the living HTML standard, which is where browser companies now build from and based off of. That's what they've put forth. This has been put forth by Carson Gross and Alex Petros. So if you may recognize some of those names, one of them is the creator of HTML itself. And if we go into the Triptych project, you can see there's the three proposals here, plus a blog post I linked to, and some of the examples of why this is actually important, and some of the history around it. If you wanna get involved, I think that's actually the more relevant call to action here, is they're looking for folks to send non-binding letters of support on company letterhead that they would be willing to support and sponsor these proposals and help weigh in on that issue. So there's a GitHub issue, that whole living HTML spec is actually maintained as a GitHub repository. anyone can join. It's not an exclusive club of enterprises and corporations anymore driving that living HTML spec. It's driven by the community itself. So if you get excited about this, go get involved, go check it out. I look forward to this being the future of browsers because we can now, especially for simple things, oh boy, would this be just nice to have this built in.
I mean, I've wanted this for like two decades. Like the fact that the button couldn't just fire an action, like having that wiring, it just makes sense. And I think this makes sense for getting things cleaned up and having less workarounds means that agentic coding tools can actually operate better because they'll have a better understanding of the semantics of this. They appreciate semantics where things are wired up and work as you expect them to.
I have a couple of things here, two things, and just a little bit of a follow-up to what I know your extra is going to be, but I'm going to wait. It's going to be a multi-staged extra, let's say. All right. I am a fan of the Granian web framework, powers Python, bytes,.fm, and many, many other things. It's a Rust-based HTTP server for Python, like think G, Unicorn, Uvicorn, that type of thing. and it's been around for quite a while. It's quite active. It's getting a lot of updates on it. More importantly, let's see. Where will one, this is Nazi. I need to learn, work on my Rust. Go to the cargo lock. More importantly, it wraps this thing called Hyper. And if you look at Hyper, that's like, it's a web server out of the Rust world that has like 130,000 stars. So basically this is like a WSGI and ASGI server that just kind of provides hyper to Python applications, right? Cool, cool. So what am I talking about? I've had Giovanni on the show and stuff before, but there's a pretty big update to it, even though it's just a 2.7.9.
Easy to do. you should easy to do it sounds like it would make a big difference you should definitely do that the next one i'm going to reshare my screen here okay do a live demo if i can find the stinking window there we go so i really enjoy doom doom was originally coded up and created on the next step os and the next machine since i actually have two next machines on my desk that have doom installed on them. I have Doom installed my iPad, but now I can have Doom installed in the terminal. And instead of usually people are saying, does it run Doom? Like that's the joke that people say, can that piece of hardware run Doom? This is a little different. This is your Doom running in SQLite. So DoomQL, you can see here, select star from hell. So if you're a fan of the game, that joke should land. But basically the frame buffer is a SQL query. So if we actually come in over here and I'll run the demo make make run. This is Doom running in my frame buffer, but the frame buffer is running in SQLite. So it uses the same standard wasad key combos. You can go and grab like power ups. There are monsters in here someplace. It is incredible. Yeah, it's tricky. It's a little trick. Oh, see, I'm getting like killed by. Oh, there's a monster right there. It just is killing me as we go. This is running SQLite. You can actually tail the SQL queries and watch all the queries that are happening under the covers if you had another window open and ran the make inspect command. So definitely check that out. It is hilarious to see that we have got Doom running in SQLite. So not just on fancy hardware, on crazy databases. Now we can run Doom.
How incredible. That is super, super neat. So that's what I had to go check it out. I don't know how I feel about it, but yeah, Doom. I used to play a lot of Doom when I was much, much younger. Much younger. I also have another real-time follow-up. How can you possibly play Doom? One of my earliest jobs was working in this place called Eye Tracking, E-Y-E tracking, at eye tracking.com in San Diego. And we did all this crazy type of research by looking at what people would see and how their eyes would react as they were solving problems and so on. So we had these weird collaborations. And one of the collaborations was this guy, I don't remember, it was like a university or something, who did stuff with EEG, I think it was, not EKG, the brain bit, not the heart bit, with the wires. And so somehow wanted to kind of understand the eye tracking side and the EEG side. What does this have to do with Doom?
And he would just think and it would turn left and they would think something else and it would shoot a gun. But what was really weird was he wouldn't think turn left and it would turn left. He'd have to activate different parts of his brain. So he's like bacon, bacon, bacon. with stars you you know what i mean like because yeah it couldn't just be the same part with motor skills it'd have to be like a different part like a like an xbox controller of the brain anyway i thought people might find that amazing that's really really weird doom's got quite a bit
let's talk about jokes i'm sure there's a bug in doom so i named this joke solving all the bugs have Have you seen this? No, I've not. Have you looked at? Okay, good. I didn't peek. Good. So I want you to put yourself in the state of, I don't know, some apocalyptic future whenever the matrix was set with Neo and Morpheus and all that. Okay. So how, in this kind of world, how would you solve the bugs? Well, it says no production incident ever exists without Jira ticket. So what if Jira tickets are the issues all along? there is no jira there is no spoon everything is perfect all right oh boy i'm ready to take the red
pill yeah let's take it thanks there is no spoon yeah you bet you bet that's amazing especially your keanu reeves impression uh very i tried i tried yeah thank you very spot well thank you for joining us this week for uh python bites all the news all the time and i'm looking forward to seeing you all next week we'll see you later
