Skip to content
PodSubs
ShowsPeopleGuestsJobsNewsEvents
More
BlogPodCred
Menu
ShowsPeopleGuestsJobsNewsEventsBlogPodCredNetworksSign in
Join nowSign in
  • Shows
  • People
  • Jobs
  • News
  • More
    • Guests
    • Events
    • Blog
    • PodCred
    • Networks
    Join nowSign in

Python Bytes

Python Bytes artwork

#498 A Tiny Episode

Sep 29, 202633 minAudio

Topics covered in this episode: MemTensor / MemoryOS PyPI package hijacked via a malicious build backend TinyMongo Jev: what to know One innocent dict read makes attribute access permanently slower Extras Joke Watch on YouTube About the show Sponsored by us! Support our work through: Our courses at Talk Python Consulting from Six Feet Up Connect with the hosts Michael: Mastodon / BlueSky / X / LinkedIn Calvin: Mastodon / BlueSky / X / LinkedIn Show: Mastodon / BlueSky / X 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. Calvin #1: MemTensor / MemoryOS PyPI package hijacked via a malicious build backend On Sept 23 an attacker published backdoored MemoryOS 2.0.34 on PyPI and three bad versions (0.1.21, 0.1.23, 0.1.25) of MemTensor's OpenClaw plugin on npm. PyPI had no clean release that day, so 2.0.34 was the newest. They pushed commits to MemTensor's own GitHub Actions release pipelines. On PyPI that was a custom Poetry build backend, and on npm a tweaked validation script. Both used BASH_ENV to hand the publish token to the attacker before the real publish ran. SafeDep couldn't confirm how the attacker got push access. Runs on import, not install: A Go implant called sckit starts when the library loads, so --ignore-scripts won't save you. It harvests credentials from your home directory (npm and PyPI tokens, GitHub tokens, SSH keys, cloud CLI tokens, .env files) and sends them to skyleen[.]fr servers. It's a worm: It uses stolen tokens to copy itself into other repos and packages, so the victim list could grow. If you installed it: Downgrade to MemoryOS 2.0.33 (plugin 0.1.20) and rotate every credential reachable from $HOME. Also kill any running sckit stage0 process and check repos you can push to for a stray runtime-update.yml workflow or .sckit/ directory. Michael #2: TinyMongo Want to use a MongoDB data interface, but swap out the storage engine? Memory for testing/caching JSON/TinyDB simple JSON files SQLite for durable, high-perf reads with WAL SQLIte shared for high write apps DuckDB + Parquet for analytics apps Postgres + MariaDB for multi-machine client/server Great for teaching, examples, and simple deployments Amazing story of paired AI development Will completely run talkpython.fm after weeks of shared work together (in SQLite mode). Calvin #3: Jev: what to know What it is: Jev is a model from TypeSafe AI that answers with typed results (yes/no probabilities, scores, picks from your options) instead of prose. Real Python published a hands-on tutorial on 2026-09-24 and the buzz on hacker news is almost deafening. It's proprietary: Jev is a hosted, closed-weight model. There are no weights to download and no self-hosting. Everything called "open Jev" is an independent reimplementation, not TypeSafe's model. Your data leaves your machine: Every call sends your input text to a third-party API. In the tutorial that path goes through OpenRouter to TypeSafe. Think twice before sending customer messages, tickets or anything sensitive. Cost and stability are open questions: The tutorial calls Jev "cheap, but not free" and says it's fast and cheap "at the moment." It also says whether that stays true is "something to keep an eye on." Credit to Real Python: It's a good, practical intro. It shows the Noul, Score and Choice primitives, and its point that instruction wording matters more than thresholds is useful advice for any model. The tutorial itself says similar results are possible with a well-prompted LLM. Open options to look at instead: JevK5 (https://github.com/allebee/jevk5): Apache-2.0 weights and code, 4B or 9B parameters, and it accepts TypeSafe-style requests. SemIf, formerly OpenJev (https://github.com/TheoLeeCJ/openjev): MIT-licensed, small models, and it can run CPU-only. openjev-sglang (https://github.com/ekzhang/openjev-sglang): a Jev-compatible endpoint running Qwen3.6-35B-A3B, but no license is stated, so check before commercial use. The catch: These copy Jev's interface, not its model or training. Results will differ, and I haven't run any of them. Benchmarks are self-reported, and JevK5 is English-only. Michael #4: One innocent dict read makes attribute access permanently slower Timofei Ivankov benchmarks a CPython internals surprise: since 3.11, attribute access skips the instance dict entirely. A specialized opcode reads the attri.bute at a fixed byte offset in the object's inline values array. Read obj.__dict__ once, though, and the dict gets materialized, the object loses that specialized path for the rest of its life, and a million-iteration loop goes from 33 ms to 51 ms on CPython 3.14. vars() and copy.copy() trigger the same thing, so a debugging print or a shallow copy in code touching your hot objects quietly makes every later attribute access roughly 1.5x slower. The slowdown is permanent and nothing about it looks like a performance decision: ordinary code far from the hot loop can trigger it, and the function that gets slower never changes. Materializing dict produces a split table, and the LOAD_ATTR_WITH_HINT fallback declines split tables, so the object ends up with no specialization at all vars(), 'x' in o.dict, and copy.copy() all materialize it; copy.copy is the realistic trap since nobody treats a shallow copy as a performance decision slots instances read attributes at exactly the same speed and cannot fall into the trap since there is no dict to materialize On the free-threaded build both effects grow: atomic incref on reads plus an object lock on writes push the penalty from 17.6 to 25.4 ns Credit: this item was surfaced by the PyCoder's Weekly newsletter Extras Calvin: whatsnewt - a TUI text adventure through what's new in Python 3.15; playful but niche. Joke: Shipping a button in 2026…

Audio and video play straight from the show's own hosting. PodSubs stores and serves no media.

Transcript

From the show. Tap a time to play from there.

Michael KennedyHello and welcome to Python Bytes, where we deliver Python news and headlines directly to your buds. This is unbelievably episode 498 coming up on episode 500, recorded September 29th, 2026. I'm Michael Kennedy.

Calvin Hendryx-ParkerAnd I'm Calvin Hendrix Parker.

Michael KennedyCheck us out on all the socials. We put all the links if you want to interact with us there at the top of the show. This episode is brought to you by us. So be sure to check out Six Feet Up if you have an amazing, you would like, People who've done a lot of problem solving in the Python space for many, many years. Reach out to Calvin and learn about Python. Got some courses over at Talk Python. They had new things coming. Nothing to announce yet, but a lot of work has been going lately on a new thing over there. So I'm very excited. Check out the newsletter. Just visit the homepage.

Michael KennedyClick newsletter. We got lots of cool things to send to you there. And with that, you have scary news. Are you going to scare us?

Calvin Hendryx-ParkerHopefully not too much. It's not quite October, although I do see lots and lots of decorations out in the stores these days for Halloween. But there is unfortunately...

Michael KennedyIt's like a jump scare, right?

Calvin Hendryx-ParkerA little bit, yeah. There's been a supply chain attack and there's no shortage of these over the last couple of years, probably due to the proliferation of AI and the tools that attackers can use to build these different exploits. This one is around MemTensor and MemoryOS. So some people may not be affected by this, but I think the real true story here is to follow how it's done and to protect your CI pipelines ultimately. So on September 23rd, an attacker published a backdoor into MemoryOS.

Calvin Hendryx-ParkerSo if you're using OpenClaw or if you have installed a MemoryOS skill into your agentic harness, you could be susceptible to this. So look for these various versions 0.1.21 on the plugin there's or that's the bad versions and 0.1.23 and 25 and then the memory os version 0.2 no sorry 2.0.34 the newest one that was released last week those are problematic they are going to launch a go process in the background even working around like the

Calvin Hendryx-Parkerimport path stuff won't get around this because it'll launch this what looks like a legitimate named thing, S-C-K-I-T. You may misview it as scikit, but it's actually S-C-K-I-T. It's a Go library that loads in the background. And what it does, scours your system for credentials, posts them to a command and control server, kind of the standard play there. And then it attempts to inject itself into other CI pipelines as a worm. So this one's not just an exploit that's and exfiltrate your credentials, they're actually looking to exfiltrate them, exploit them,

Calvin Hendryx-Parkerand then turn them into a worm to gather more and more of them, whatever projects you're basically working on. So it traverses your home directory looking for PyPI tokens, GitHub tokens, you name it, and then sends them to a nefarious server someplace. Those then locate itself and try and go again. So if you are on these various versions of these various packages, make sure downgrade to the safe versions, the 2.0.33 of memory OS and 0.1.20 of the plugin and rotate

Calvin Hendryx-Parkerevery possible credential you have that's reachable from your home directory. Make sure you kill any SCKIT processes that are running because that is where it is talking to the command and control server. So unfortunate news, no fun. The write-up from SafeDep, which is linked to from the show notes here has a really good take on basically how they got in there's a couple spots where they don't know how they got some of the tokens they assume maybe social engineering or a leak of a

Calvin Hendryx-Parkergithub token someplace but the various projects have put in some fixes into their ci pipelines to hopefully prevent future attacks like this from happening and you probably could learn something a thing or two for your own ci pipelines to harden your processes as well that is a jump scare Yeah, less than fun. Less than fun. No one loves to hear that news on a Tuesday morning. But I think everyone needs to be aware and protect their CI pipelines. Because again, this is how they got in. They basically used the GitHub Actions pipelines.

Calvin Hendryx-ParkerNot that GitHub Actions is in itself vulnerable to these things. It just enables these kinds of things. It's the other practices that are what made this possible.

Michael KennedyI remember how scary it was that there were worms on the internet, especially back when firewalls, what's a firewall? That's what a company, that's what like giant companies do.

Calvin Hendryx-ParkerYeah. So there's, on the webpage, they also link into the issue from the MemoryOS folks and the OpenClub plugin repositories. Again, I think it's a good responsible write-up of what happened. The repositories themselves don't have a lot of information on them, but this article does.

Michael KennedyYeah. It's just, it's scary, you know, having very cool what we can do as developers, but at the same time, the responsibility of, oh my gosh, something got through and it didn't just affect me. It didn't just affect my users, but everybody who might have used something I created now, it's like taking over all of their music. Oh my gosh, that's a serious fire. So. I mean,

Calvin Hendryx-Parkerit's a common complaint. Like, why can't we just dump files into a web route like we used to and deploy CGI applications? Because that was very dangerous. We just didn't know it yet because of the various vectors for exploit and attack. Deploying software safely requires a thoughtful and intentional process.

Michael KennedyYeah. And to some degree, safety and isolation of your computer that makes that software.

Calvin Hendryx-ParkerVery true. So yeah, pay attention to a lot of the sandboxing and containers and things like that that help you with those processes.

Michael KennedyWould you say you got to pay attention to like tiny little issues?

Calvin Hendryx-ParkerTiny things could, you know, be an interesting way to go.

Michael KennedyI want to talk about Tiny Mongo. Are you familiar with this?

Calvin Hendryx-ParkerI am not, actually. I'm quite curious. My son actually was in a MongoDB hackathon over the weekend, so maybe he might be interested in this.

Michael KennedyThis would have been absolutely awesome for that. I mean, maybe if it was about MongoDB, no. But I've covered this before, actually. Gives me a chance to highlight a cool little search feature of our, if you search them, you can actually say, only show me the episodes that exactly covered this. So way back in 2017, nine years ago, we covered Tiny Mongo. So the guy behind this, Steven, I had posted way back when I had posted some issue saying, this thing is cool. So let me tell you what TinyMongo is, and then I'll tell you why it's back on the show after

Michael Kennedynine years. So TinyMongo is what SQLite is to Postgres. TinyMongo is to MongoDB.

Calvin Hendryx-ParkerOkay.

Michael KennedyIn process, local file, but it goes, I don't know, it goes a little farther than SQLite, as you'll see, in some really interesting ways. but it uses well-known durable backends for the most part. So you can choose a really well-known, well-tested, well-trusted backend for this. But basically think in process, I want something without a server. Now, as part of this news item is very, very fast. So Stephen looked at this GitHub issue and decided, all right, I'm going to fix it.

Michael KennedySo the issue I filed a while ago was, this is really cool. It supports a subset of MongoDB, but not enough. Okay. So I was using, when I posted the issue, I think I was using MongoEngine. When he replied to the issue, I was using, what one was it? I was using a Pydantic-based one, Beanie. And then by the time he actually got the thing working, I was using just raw MongoDB queries. But I said, look, this is cool, but I can't use it with anything based on these ORMs because the ORMs have a certain set of startup things they do.

Michael Kennedylike ensure these collections exist, ensure this index exists. You know, it's like testing different things as just part of the standard setup, you know, like it scaffolds the index automatically and stuff. And those things weren't working. So I said, would you be willing to put in enough structure, maybe even if there are no ops, that I could actually run a quote real application on top of tiny Mongo? Because there's all sorts of cool reasons you might want this. Like if you're doing a tutorial or a workshop, you don't want to have to start out and go now kids, The first thing we're going to start is by setting up a network server and securing it.

Michael KennedyLike, no, no, no.

Calvin Hendryx-ParkerYeah, there goes the day.

Michael KennedyYou're like, okay, well, we're not doing the workshop anymore, right? But if you have something like SQLite, you can just say, this is the connection string. This is the uv pip install command. Now let's keep going. But it's the same program. You just change the connection string basically to get like a real server, right? Like to switch over to real Mongo or whatever. So Stephen took that idea and just totally ran with it. and came back to me and said, hey, look, what do I need? How about this? You know, this last question was asked in the time of AI,

Michael Kennedythe time of really smart coding agents, right?

Calvin Hendryx-ParkerJust the before times and there's now.

Michael KennedyExactly. So I think this actually represents a really super interesting collaboration between me and Stephen. So, Stephen, sorry. So he said, well, what do I need? I said, well, how about this? why don't I just see if I can get Talk Python to run on top of this, just as it is? And I just said, all right, well, I'm going to take Mongo out. I'm going to stop talking to the real Mongo. And I'm going to put Tiny Mongo in and get it to run. And there were all these issues like, yeah, it technically works, but this thing is a thousand times slower in this way.

Michael KennedyIt's like, oh. Interesting.

Calvin Hendryx-ParkerI wasn't expecting that.

Michael KennedyYeah. Well, it almost worked. Once we got it working, it was like, okay, now it works. But it's like, these five things are insanely slow. this type of query is not actually supported or limit doesn't actually limit it in the DB. It pulls it all back and then it like limits it in memory. You know, those kind of weird little, like it's fine. But if you've got hundreds of thousands or millions of records, you're like, no, this is not going to fly. This is out of control. So we went through all those and now it's like really quite close to MongoDB performance.

Calvin Hendryx-ParkerMichael, would you recommend this for production usage or is it still more for exploring, playing, teaching?

Michael KennedyI would recommend it. I think it's safe. I'll tell you why. I'll tell you why. I think it's, I would recommend it. If you would consider SQLite as your backend for production, which I think actually is viable.

Calvin Hendryx-ParkerYeah, it's very safe.

Michael KennedyI think that's very safe. It has restrictions on like parallel writers and stuff, but I do think it's quite safe. I agree. If you would consider SQLite as a backend, then I think this, I would recommend this as a backend. Yes, as we'll see. Okay, so let's go down. I mean, what's cool about it is the way you write is you just like write regular code and you just import tinymongo as PyMongo, which is the standard way of creating a thing. And you give it a connection string sort of deal that is like this file instead of this database. And then you just write regular queries against it,

Michael Kennedyright? So what's really neat down here somewhere is all the different backends it has. So like SQLite, it might maybe even uses the SQLite version for this, I'm not sure, is you have an in-memory version. So it never even writes the disk. Like I'm doing unit tests or I'm just firing up this code, this data, I'm going to think about it and then throw it away. Right. That's pretty cool. It has this JSON backend, which is it's sort of default way. I haven't done it. This was not really able to totally solve the Talk Python runtime, I think, or it was like too slow or something.

Michael KennedyBut switching to SQLite. So basically it uses SQLite with all of the SQLite transactions, write ahead log stuff and all that kind of stuff. And that's a really good production story. And then look at this, Calvin, sharded SQLite.

Calvin Hendryx-ParkerI'm more curious about the next one, which is DuckDB.

Michael KennedyYeah, so you're going to ask.

Calvin Hendryx-ParkerYeah, because there you've got real JSON support possibly.

Michael KennedyYeah, Stefan is a huge fan of DuckDB and those kinds of things. So this is DuckDB and Parquet files as the backend, which is pretty interesting. So if you're doing data science-y things and you were doing Mongo type of queries, this is the way. This is a pretty good one. And then also it has a way to say like, you know, point that over at Postgres and MariaDB if you'd rather have something that's kind of like Mongo, but you don't actually run Mongo. I mean, you literally talk to it as if it was Mongo.

Calvin Hendryx-ParkerYeah, I'm unsure about that use case. I think it might just run Mongo.

Michael KennedyI would too. I would totally too. But I think the SQLite one, it's really good. We got it really, really dialed. So I actually linked to one of the issues. There's a bunch of issues over there. So I had some issues. Steven added him and sort of referenced me. And we just went back and forth. And I would say, hey, Claude. I'd open up, I had a branch for Talk Python. I'd open it up and said, hey, Claude, check out this GitHub issue. Can you try to implement it on top of this thing? And he would do it and say, well, I found all these issues. I said, okay, file some issues. Then Steven would have Codex look at it, fix it up,

Michael Kennedyreply. And we would just pass it back and forth. And the reason that's interesting is I'm not giving him the Talk Python code base. And I ended up running on Talk Python training, which is like 300,000 lines of Python code and got it working there as well. But I'm not giving him that code. But he was able to literally prototype both from a performance and correctness perspective running on both those code bases by just bouncing back and forth. Well, my AI did your spike and it found that it ran like this and this worked and this didn't. And so, okay, I fixed this, try it again.

Michael KennedyAnd we just went back and forth for like over and over for days and got it really, really dialed. And I thought that was, that itself is worth covering here. Yeah, I like that workflow. Yeah, yeah, it's very interesting. Obviously, my prompts were like, you will not put any proprietary information, any secrets, any source code example. You will put all generic, you know what I mean? But at the same time, it totally worked. And it was really cool. But I think this is a super interesting thing because until this recent work,

Michael Kennedythis version 1.3.1 that got released, There was no SQLite equivalent for MongoDB. And now I think there legitimately is. It's not 100% coverage, but it's quite high. It runs multiple real-time apps.

Calvin Hendryx-ParkerYeah, I like that. Well, especially for the education market, being able to teach someone really quickly without having to install and serve. And that's a huge barrier for a lot of people.

Michael KennedyYeah.

Calvin Hendryx-ParkerIt looks really good.

Michael KennedyI'm really excited about it. Thank you, Stefan, for doing this work. And there might be a follow-up at some point as well.

Calvin Hendryx-ParkerAnd what a great story for open source.

Michael KennedyYeah, exactly. Like a really cool way to get some actual hands-on experience on real projects by sort of ping-ponging GitHub issues back and forth. It was crazy. Speaking of crazy, I've heard this topic is setting the world on fire.

Calvin Hendryx-ParkerWell, and I wanted to bring it to light to get some people some exposure to it. If you've not heard of Jev yet, you're probably living under a rock someplace, and that's okay. But the folks over at RealPython did a tutorial of how to get started with Jev in Python. For those of you who don't know, Jev is a model from a company called TypeSafe AI that answers typed results like yes, no's, probabilities, scores, and pick from options instead of you talking with it. So you don't chat with Jev.

Calvin Hendryx-ParkerYou don't come into Jev and say, hey, build me an app or tell me a bear story or whatever the thing you may want. propose to JEV sets of information, evaluation, the kind of result you want. And then JEV can, in parallel, evaluate those things, either scoring them, giving them yes-nos. I mean, the docs from the tutorial are basically a customer service example where the customer says, I've tried contacting support like three times. Can I please get escalated? And so then the JEV for that basically is, here's how you know if the person is telling the truth or not. So they have a

Calvin Hendryx-ParkerYesNo or TrueFall. And there's some custom various data types that go along with it. So what's nice is that the real Python article will get you started with Jev. So you'll understand the data types. You'll understand like what Jev's about, that you can't just chat with it. But I think, and the buzz is real. Like I've heard tons and tons of people talking about it. It looks like the invites are back open again. I was actually able to sign up for Jev this morning and try it out, but it is proprietary. Jev is a hosted closed wait model. There are no waits to download. There's no self-hosting of this thing.

Calvin Hendryx-ParkerEverything called OpenJev is an independent implementation and not TypeSafe's model, which means your data leaves your machine. So I don't know how much you trust TypeSafe AI. I don't know who they are, where they're hosted, what their business models are. Obviously, it's not free. You have to put a credit card down to use this model and try it out. But every call sends your input to the input text you put in there to a third party. So be careful, like much like you just mentioned how you are sanitizing your inputs

Calvin Hendryx-Parkerfor working back and forth on the tiny Mongo project with Stefan, be careful what you send into this one because you don't control it just as much as you control what you send to Anthropic or OpenAI. Those are pretty well established companies with a good business model and they seem to be running on, you know, credibility and reputation. You have to do your research and know what you're gonna be sending over there. So think twice before sending customer messages, tickets or anything sensitive. The other thing is like costs and stability are a question, right? So basically Jev bills themselves as very cheap and it is very cheap. Like you can,

Calvin Hendryx-Parkerand very fast, you can have it sort through. I heard someone tell me an example, like look through my inbox of a million messages, categorizing them for like needs immediate attention, is about a customer, et cetera, et cetera. And it can build you a table and sort that table in just milliseconds. It's that fast. I want to give people an option here. It's a good practical intro. It shows how to use the null, the score, the choice primitives, but there are open options out there. I know I keep caveating this like episode, this, this section of the episode.

Calvin Hendryx-ParkerThere are some open options to look at instead. For example, Jevk5, it's an Apache 2.0 licensed weights and code. So that's kind of my front runner right now. I've not tried it, but it does accept type safe style requests. These are API compatible, but they are not the JEV model. So you're going to get different potential results. There's also one called SimF, which was formerly called OpenJEV. I'm sure lots of takedown notices came flying back and forth as all these alternatives came out that were also called something something JEV.

Calvin Hendryx-ParkerAnother one's OpenJEVSGLang. Again, the catch here is these are not the JEV model. They are close. There was actually a really interesting JEV in 25 lines of Python, on a little bit tongue in cheek post that also came out about this. But what they did here was use the Quinn three model and told it to act like Jev. And for most things, I think it gave reasonable results, but also at the very end, this was a real tongue in cheek post kind of poking fun at the hype that is Jev right now.

Calvin Hendryx-ParkerSo I wanted to put that out there for folks to be just mostly aware of the fact that you're sending your data to a proprietary company and be careful what you're sending to it totally trust it and have a business agreement with that organization beyond putting your credit card into a credit card field. So I hope folks are vigilant as they go forth and try these things. The hype is real. Oh my gosh, you couldn't again move last week without hearing about Jev in some meeting and some article and some topic. It's a very interesting way and a very interesting usage.

Calvin Hendryx-ParkerIt's a very, I think it's a great pattern for reducing token spend and usage on other models collaboration or combination with other models, but you need to understand what it really means in action.

Michael KennedyIt's a super cool thing. You're right. It's absolutely blowing. Jev is blowing up. I had to watch some YouTube videos this week. I'm missing something because there's a lot of this thing I've never heard of going on around and around.

Calvin Hendryx-ParkerWhen you sign up for a Jev account, it makes you take a pop quiz to ask you whether or not you can chat with Jev. I won't give you the answer because if you don't know, you shouldn't probably be using Jev.

Michael KennedyIf you got to ask, It's not for you.

Calvin Hendryx-ParkerYeah.

Michael KennedyI was going to say that there's never been a time, I think, where we're sending as much detailed information to other companies and other places as the last couple years.

Calvin Hendryx-ParkerBe careful out there, folks. It's real. Yeah.

Michael KennedyBut the reason we're doing it is because it's so productive and so useful, right?

Calvin Hendryx-ParkerIt is. I mean, the patterns, I think, in looking at some of those open wide options, if you can put in place, again, I'll stress, probably why I stressed things last week. was around evals. Building good evals for your CI pipeline to run against these models, whether they're classifiers like JEV or whether they're LLMs like the QIN or other open weights models, means you can swap back and forth with confidence. And if you can do that, you can use one of these open weights models, open source, even versions of these models with more confidence on your own GPUs. These things will run on even very small CPU,

Calvin Hendryx-ParkerGPU. I think there was a QIN 306B model that they're using in the parody article that runs on like a raspberry pi you can get those anywhere

Michael Kennedynice but i'm not using Anthropic for something i've been using glm53 flash and that's been super super neat but i want to talk about an age of innocence that may be over here this is an article i don't typically cover articles i typically more but but it kind of pulls out it highlights a really important thing that the reason i pull it up is because it kind of broke my understanding of Python performance tips for one particular axis. So this is by Timothy Ivankov. So cool to write this up.

Michael KennedyI think it might have had a little writing help, but that's okay. So here's the headline. It's reading Dunderdict once, one time. Reading Dunderdict of an object permanently de-optimizes attribute access. What? Why is that? Why is that not good? And I was a wonder's point of this comes from PyCoder.

Calvin Hendryx-ParkerThe permanence of it is the striking bit.

Michael KennedyPermanently, for the rest of that object's life cycle, its performance is broken. Okay, so here's an old performance tip. And I'll tell you the one that I used that I thought was amazing. And it was amazing. If I have a loop and in this hot, let's call it a hot loop here. This is an example. A million times around, we're just going to do the same thing. Like we're going to say, create an attribute, self.value, access self.value in the loop, increment plus equals on the self.value. Well, traditionally, that would go into the DunderDict, find the value,

Michael Kennedypull that value out, change it, store it back into the DunderDict, right? That was the backing store for its fields, which is weird, but that's how it worked. So here's what you do. Instead of doing that interchange over and over and over, do it on a local variable. Create a value, do all your work on a local variable in the function, and then at the end, set the value to the class, right? Create a value, and then eventually say self.value equals value, right? Super simple. That used to make a big, big difference. And now it does still a little bit,

Michael Kennedydoes a little bit. So it technically works. However, if you do this enough times, it turns out that the new specializing adaptive interpreter notices that and it drops the load adder, which is the bytecode instruction that reads the field from the dictionary. Eventually it drops it and it starts processing it different, right? And so what it does is it actually starts to look at just, well, where in the offset, like a fixed byte offset into the object's storage for this,

Michael Kennedywhich is like, wow, okay, pretty cool. So that's, I think, since 13, really interesting. And you can see the different aspects. It turns out that it's even more significant, this change of the problem they're suggesting or pointing out. Is that really a problem? It's just breaks in optimization. that the breakage is stronger in a free threaded world. And the article goes into why. So check this out. If you just say, like maybe this is like a debugging thing or whatever, you just say print dunder dict of the object and then you go have that function run.

Michael KennedyAll of a sudden it's 50 milliseconds instead of 30 milliseconds. 1.5 times slower. What do you think?

Calvin Hendryx-ParkerIt's intense to get down to that level.

Michael KennedyIt is, but there's a bunch of little simple things that you're like, I could read the fields or I could just say star star dunderdict and do this and that. And it turns out that that actually, it didn't used to make any difference, but because of the specializing adaptive interpreter, now it does, right? So like if you just ask vars of an object or if you ask if a field is in the dictionary, well, here's the really tricky one, a shallow copy, right? Like, well, that's a totally reasonable thing. I'm going to clone this before I hand it back or something.

Michael KennedyWell, that clone that you did, it can attribute access.

Calvin Hendryx-Parkerto access it yeah it makes it 50 slower i've definitely done that mostly when i'm debugging or triaging code or kind of walking through the interpreter because it's easy to access i can't think of too many times where i would have tried to do it in code you could see how it's a it's an easy workaround it's like oh it's just right there i'm going to reach for it yeah exactly so these

Michael Kennedythe the first three like are kind of um debugging ones but this last shallow copy this is a legitimate thing, right? That you might do. And so here's the, this is the part that I didn't get because the world has changed and I haven't been like prototyping everything at that level. I'm a big fan of dunder slots. It means you can't dynamically add stuff to your class, but more importantly, used to mean that this whole dictionary mechanism was no longer used. And it basically used an offset into a list that was just in each instance.

Michael KennedySo it honestly made things a lot better in terms of memory and in terms of attribute access was significantly faster. Well, apparently slots makes no difference anymore because the specializing adaptive interpreter, at least in this use case, right? This is like a, I'm accessing the same thing a lot of times, right? It could be, you know, profiling is tricky. Performance is tricky, but basically the specializing adaptive interpreter for hot pass slots versus not didn't really matter.

Calvin Hendryx-ParkerAnd I didn't know about slots until I read Luciano's book, Fluent Python. That's where I discovered that. And now you're saying it really doesn't matter anymore because of the new bits in there.

Michael KennedyYeah, exactly. So I believe I might have learned about it as well from Luciano's book. So yeah, 3.11 and beyond, there's a lot of the faster CPython thing. Changed some of these things. And it changed how this, especially with the specialized and adaptive interpreter, changed a lot about how this dictionary and access, and that's the whole story, slots, dictionary access, optimizing or not optimizing it, and so on. So I thought this was an interesting dive into something that's, you know, everyone uses classes,

Michael Kennedyobjects, even if they're not big OOP folks, you still create objects. I mean, do you have a number? You know what I mean?

Calvin Hendryx-ParkerWell, it's just, and it's convenient, but I think if you were, again, performance debugging and reaging and you ran into this, you've been surprised. Yes,

Michael KennedyI would. I would certainly say so. I would say so.

Calvin Hendryx-ParkerMichael, would you want an interesting way to find out what's new or what's newt in Python? So I got this extra here I wanted to share. This is cool.

Michael KennedyI've seen this now. I

Calvin Hendryx-Parkerthought I had not seen. I've seen this is cool. This is a dungeon crawler called what's newt. And it, but what it does is it runs you through the what's new in Python. And this version is specific for 3.15. You can't run it with prior versions because it actually uses the features in 3.15 to check that you've completed the challenge in the dungeon. So I've got the dungeon up right here. So I'll just read off real quick. So this one starts off with the first room of the interpreter and the one nobody sees. Slips of paper are wedged into every crack of the masonry.pth

Calvin Hendryx-Parkerfiles. Hundreds of them, each one adding a directory to the path. A few begin with the words import. And those have scorch marks, rightfully so. A brass plaque is bolted to the wall. A new file sits on the lectern beneath it, unwritten. And so at this point, you have a puzzle, which is what runs before your program does. And it has a link actually in the terminal. That is a hyperlink. It's a nice little TUI app. And when you click on that, it'll open up the related PEP to basically give you a hint for it. So if you want to solve it, you just type solve.

Calvin Hendryx-ParkerI'll type solve. It'll my butt because it does not have VI key bindings in there. So I had to like use my arrow keys.

Michael KennedyYou probably had almost just like a caveman.

Calvin Hendryx-ParkerAnd so based on the PEP 829, it added in the new namespace, a callable syntax for bringing in a callable into your PTH file or the new sys.path, for example. So they're deprecating the word import. And now 315 adds this file format that can only name a callable. Here's how you write it. And when you click check, it's like solved. A reader can now see what starts up without executing it. The site modules batches every static

Calvin Hendryx-Parkersys.path extension first, and then only runs the startup callable so that a.start file can rely on the path being complete. Please press enter when you're finished reading. And then it takes you into Do you want to go north, south, east, west on your journey and learn more? And tracks your progress so you can see what scores I've gotten, how many puzzles I've solved.

Michael KennedyIf you go east, it's a very lazy path.

Calvin Hendryx-ParkerYeah. So that's super fun. I've not spent enough time reading the what's new in newer versions of Python, kind of like you alluded to in the last article, because we just use Python. And a lot of times I'm not leveraging some of these new features, but this is a fun way to learn what they are. I figured I'd throw that in there.

Michael KennedyOh, it is very fun. This is from Barry Warsaw, right? I believe so.

Calvin Hendryx-ParkerThat's a good question.

Michael KennedyI believe so. What's new? It is. You're right.

Calvin Hendryx-ParkerIt is Barry Warsaw. Yep.

Michael KennedyGood job, Barry.

Calvin Hendryx-ParkerNice work, Barry. I love it. I'm here for it. And especially with the hype around Dungeon Crawler Carl right now, this is very appropriate.

Michael KennedyBrings me back to the days of MUDs. I used to play multi-user dungeons. I mean, me and my friends, we would spend tons of time in these places back in high school. People got to remember when I was in high school, there literally was no web. Not like it was bad.

Calvin Hendryx-ParkerWe're dinosaurs roaming.

Michael KennedyThe worldwide web, I know. The whole thing was created in 1993 when I was in college. So before that, you're like, well, we got Telnet. What are we going to do, folks?

Calvin Hendryx-ParkerYep.

Michael KennedyMuds. That's what we're going to do.

Calvin Hendryx-ParkerWe're going to use Gopher.

Michael KennedyIt was a lot like this. Yeah. Gopher, Archie, Telnet. Oh my gosh. News groups.

Calvin Hendryx-ParkerYeah. Get your newsreader out.

Michael KennedyWhat's so ironic is it was so amazing. And it seems so futuristic.

Calvin Hendryx-ParkerI bought things off of news groups, like going in through Telnet and then getting the news groups. And I bought an expansion card for my HP 48 GX.

Michael KennedyIncredible. All right. Well, from the past to the future, well, to the present, which feels actually legitimately future.

Calvin Hendryx-ParkerTell me about the future.

Michael KennedyThings used to be so simple. You mentioned throwing just a set of files to a folder and you may be behind a C panel so you can admin your website.

Calvin Hendryx-ParkerOh, that was almost too modern for me, C-panel.

Michael KennedyYeah. Yeah, just FTP it up. I'm sorry. Not even SFTP, just straight FTP. Just open FTP. So I want to come back and do one more Kyle Lintit because I couldn't help myself, Calvin. I saw, oh my God, I saw this one when we talked about the big data video. So here's more homework for folks. This is the perfect encapsulation of just how stuff gets so complicated for such a simple thing. So here's this 10-minute video.

Michael KennedyIt tells the story of multiple mini personas throughout that we experience as software developers and data scientists and so on, trying to build tools, just a simple thing. You know, it starts with, okay, I need you to build a dashboard with a single button that does, I don't know, you know, whatever the button does, right? Pretty soon, there's this guy over the shoulder and says, what about what are you doing with a regular database you need a graph database he goes i don't need to have a graph database for 200 000 users he goes what if we had 200 000 200 000 and

Michael Kennedyone users he goes gosh his delivery is genius in this one it's so good so good my highlight was the

Calvin Hendryx-Parkerpearl guy pearl pearl you know devil shows up on his shoulder yeah it does yeah there's this this

Michael Kennedyother guy's like well we need a ddd you know domain driven design bounded context for the button we need docker builds for the button it just goes on and on and just oh it is absolutely good and the pearl guy somewhere farther it is like i could have built this with a single pearl script and a cron job back in you know whenever but you portray them perfectly i mean if you've

Calvin Hendryx-Parkerbeen around any amount of time in this world you're gonna you're gonna laugh yeah yeah yeah it's it's

Michael KennedySo good. So everyone, I leave you with a delightful, too realistic look at how software is built these days.

Calvin Hendryx-ParkerYeah.

Michael KennedyWell, this was really, really a good episode, Calvin. Like you said. Yeah. Catch you later.

Open the transcript file

Hosts and Guests

Nobody is credited on this episode yet.

Credit the people on this episode

Be the first to rate this episode

More episodes

All episodes
  1. #505 Introducing diskcache-oxide

    Nov 17, 202640 minAudio

    Topics covered in this episode: tinyjobs: a SQLite job queue goes free-threaded funkycache: cache Python functions in SQLite Ghostman - a keyboard-driven terminal API client diskcache-oxide: A shared, durable disk cache...

    Credit the people on this episode

  2. #504 Who turned the GIL back on?

    Nov 10, 202630 minAudio

    Topics covered in this episode: PyPI's redesigned project pages now warn when provenance changes gilguard catches the import that turns the GIL back on pip 26.3: pylock extras, and pip says plainly that untrusted wheels...

    Credit the people on this episode

  3. #503 It’s not 85% HTML

    Nov 3, 202630 minAudio

    Topics covered in this episode: Your GitHub language bar is lying (how to fix it) Python Typing Survey 2026: developers mix type checkers, and AI is writing the hints Flask Vibe - Build Apps You Can Understand Python on...

    Credit the people on this episode

  4. #502 Introducing chameleon-rs

    Oct 27, 202634 minAudio

    Topics covered in this episode: PHP wasn’t the only problem last week chameleon-rs Bringing uv and ty together Stlite runs Streamlit apps entirely in the browser Extras Joke Watch on YouTube About the show Connect with...

    Credit the people on this episode

  5. #501 A Nod to Sir-Mix-Alot

    Oct 20, 202638 minAudio

    Topics covered in this episode: Nod: pause your Python program and open a notebook at any line Polars 2.0 ships: streaming engine by default, spill-to-disk, and a row-order gotcha django-cachalot caches your ORM queries...

    Credit the people on this episode