Latest / Talk Python To Me / #369: Getting Lazy with Python Imports and PEP 690
Transcript
- 0:00Python is undergoing a performance renaissance.
- 0:02We already have Python 3.11 20-40% faster than even Python 3.10.
- 0:07On this episode, we'll dive into a new proposal to make Python even more efficient using lazy
- 0:13imports laid out in PEP 690.
- 0:15We have all three folks involved on the episode, Carl Meyer, Hermann Bravo, and Barry Warsaw.
- 0:20Are you ready to get into making Python faster still?
- 0:23Let's dive in.
- 0:24Welcome to Talk Python To Me, a weekly podcast on Python.
- 0:42This is your host, Michael Kennedy.
- 0:43Follow me on Twitter where I'm @mkennedy and keep up with the show and listen to past
- 0:47episodes at talkpython.fm and follow the show on Twitter via at Talk Python.
- 0:53We've started streaming most of our episodes live on YouTube.
- 0:56Subscribe to our YouTube channel over at talkpython.fm/youtube to get notified about upcoming
- 1:02shows and be part of that episode.
- 1:04This episode is brought to you by Sentry and us over at Talk Python Training.
- 1:08Please check out what we're both offering during our segments.
- 1:11It really helps support the show.
- 1:13Transcripts for this and all of our episodes are brought to you by Assembly AI.
- 1:17Do you need a great automatic speech-to-text API?
- 1:20Get human-level accuracy in just a few lines of code.
- 1:22Visit talkpython.fm/assembly AI.
- 1:25Hello, Barry, Erman, Carl.
- 1:27Welcome to the show.
- 1:28Hey, hello.
- 1:29It's wonderful to have you all here.
- 1:30I'm very excited about the work that you're all doing around Python performance.
- 1:37We're going to focus on imports and this PEP that you three proposed today, but it's really
- 1:43just the tip of the iceberg in terms of a bunch of cool stuff that's going on.
- 1:47So I'm very excited to dive into that with the three of you.
- 1:49Now, before we get to it, though, let's just do a quick round of introductions.
- 1:53Barry, you've been on the show before talking about 1994 Python stuff and other things.
- 2:00So maybe just a quick introduction for yourself.
- 2:02Yeah.
- 2:03Barry Warsaw.
- 2:04So I'm still here hanging around, I guess.
- 2:07You know, I should mention, you know, as we get into this PEP, though, I'm really just
- 2:12the sponsor.
- 2:13You know, I got to hand a lot of thanks to Jeff Hermann and Carl for doing all the work
- 2:18on it.
- 2:19You know, most PEPs these days, you know, require a core developer to sponsor.
- 2:24I'm just super interested in the topic.
- 2:26I think it's a super clever approach.
- 2:28And so I think it'll help specific needs that I have at work.
- 2:33And so I was really eager to sponsor it.
- 2:37Yeah.
- 2:38Fantastic.
- 2:39Yeah.
- 2:39All right.
- 2:40Very cool.
- 2:41Hermann, how about you?
- 2:42I'm just working at Mana with Carl and I wrote the initial approach for Licey eports.
- 2:48And well, here I am.
- 2:49Right on.
- 2:50Carl, quick introduction.
- 2:51I've been around the Python community for a while.
- 2:55I think the first maybe semi-notable thing that I did was write the first version of PIP
- 3:01uninstalled back in 2009.
- 3:02And that led to being a maintainer of pip and virtualen for a while.
- 3:07And I worked on the Django core team for a while.
- 3:10And so, yeah, I've been doing Python things for a long time.
- 3:13And I've been working at Meta.
- 3:14Those are a lot of big projects there.
- 3:16Yeah.
- 3:17They're projects that I was using.
- 3:18And so I was interested in working on them.
- 3:20And same goes for Python itself.
- 3:22Yeah, absolutely.
- 3:23And sorry, I kind of cut you off there.
- 3:24You said working at Meta since 2016.
- 3:26Is that what you said?
- 3:26Yeah.
- 3:27I've been working at Meta since 2016.
- 3:29Working mostly on how Meta uses Python, how Instagram uses Python.
- 3:34Yeah.
- 3:34There have been some really cool looks inside what's going on, especially at Instagram.
- 3:39there with some of the typing talks that Lucas gave, as well as sort of suspending the garbage
- 3:45collector for other various things.
- 3:47And a lot.
- 3:47Was that you guys?
- 3:48I think it was, right?
- 3:49Yeah.
- 3:49We had a whole.
- 3:50A lot of neat stuff.
- 3:51A whole saga.
- 3:52We turned off the garbage collector, turned back on the garbage collector.
- 3:55There's been multiple blog posts along the way explaining why we've done each of those
- 3:59silly sounding things.
- 4:00Sure.
- 4:02I mean, they seem insane.
- 4:03Well, a lot of the projects that a lot of the stuff that's coming out of here has to
- 4:07do with the Cinder project.
- 4:08Right.
- 4:08Yeah.
- 4:09And maybe, I don't know who's best to give the introduction for Cinder, but Cinder's a really
- 4:14cool project about, you know, taking a whole bunch of optimizations and specializations you
- 4:20all have done and sharing that back with the community a little bit, right?
- 4:23Yeah.
- 4:24So we started Cinder in, I think, 2017 or 2018.
- 4:27There was actually two projects kind of started simultaneously.
- 4:31We realized around that time that the trajectory for Instagram's kind of server footprint was
- 4:37not really sustainable just in terms of how much server CPU time we were spending running
- 4:41Python code.
- 4:42And so we kicked off two projects.
- 4:44One was called, it's now called Sky Bison.
- 4:47It was like a ground up rewritten Python interpreter, you know, using all the modern dynamic language
- 4:53VM ideas, like a moving garbage collector and all these different things.
- 4:57We weren't the first people to try that.
- 4:59And we also weren't the first people to fail.
- 5:02And that project was wound down last year, just weren't able to get the performance, particularly
- 5:07trying to emulate compatibility with the C API and all the C extensions, which is the same
- 5:12reason many prior rewrite efforts didn't go very far.
- 5:16So at the same time as we kicked off Sky Bison, we had sort of kicked off what we thought was
- 5:21a short-term project of just like, what can we squeeze out of CPython?
- 5:24Where can we get a little more performance out of it?
- 5:27And that turned into Cinder and then ended up kind of becoming our primary approach to
- 5:31Python performance.
- 5:32Isn't it always the story that the C interop stuff is the big sticking point here?
- 5:38I mean, Barry, you must have seen a whole bunch of examples from a core-to-of perspective on
- 5:43that, right?
- 5:43If we could just change the gill, but the C API defense, but if we could just, but, you
- 5:49know.
- 5:49Yeah.
- 5:49Yeah.
- 5:49Yeah.
- 5:50Yeah.
- 5:50Yeah.
- 5:50I mean, it's both, you know, Python's, you know, advantage, you know, pros and cons,
- 5:54right?
- 5:54Like the approachability and the usability of the C API has led directly to the incredible
- 6:02ecosystem of extension modules.
- 6:04Right.
- 6:05But those also are also the hindrance for moving, you know, ahead in a revolutionary way
- 6:10with the interpreter, I think.
- 6:13Right.
- 6:13You kind of got to live within the box with the walls that are put up by those constraints.
- 6:17But I do think it's super important.
- 6:19You know, a lot of people would maybe just think, well, let's just get rid of it.
- 6:21Like, let's just try to move beyond it.
- 6:23But when you hear people say that Python is slow or it has these other problems, so often
- 6:28what you'll see is, well, and what I did was I did a for loop in Python and did some math
- 6:33and that was slow.
- 6:34It's like, well, but if a thing is slow, so often that gets rewritten in C and then all
- 6:38of a sudden it's faster than, I don't know, what Java or whatever else it is they're trying,
- 6:42you know, node, but they're trying to compare it to.
- 6:44And so there's this kind of crazy switch that gets flipped for like really high performance
- 6:49and then, you know, maybe acceptable most of the time performance.
- 6:53And it's this interop with C that is the thing that's the escape hatch.
- 6:58At LinkedIn, we don't, you know, we don't have the same kind of workloads that they have at
- 7:02Meta, but, you know, we've done analysis.
- 7:06One of the reasons why I was particularly interested in this project is because we write a lot of
- 7:10our CLIs in Python.
- 7:12And so, you know, we've had proponents of other languages say, you know, complain, hey, Python's
- 7:17really slow.
- 7:18So I write a CLI in Python and then it takes a long time to start up.
- 7:22But if you actually do the analysis, what you find is that people are not writing a lot of
- 7:28the internal libraries that those CLIs import do things like they go hit the network and they
- 7:32go try to do the service and create really expensive resources at module scope time.
- 7:37Right.
- 7:38So like those are the types of analysis that you really need to do to say, is it really Python
- 7:42or is it the way we use Python?
- 7:44You know, for us, it's a little of both for sure, but often it's sort of the way Python is being used
- 7:49in a non-idiomatic or not in the highest performance way.
- 7:53Right.
- 7:53It's a little bit of rewrite of some internal code can get you a long way.
- 7:57It sure can.
- 7:57Also, I want to just give a quick shout out back on episode 347.
- 8:01I talked with Dino VLAN like all about the Cinder project.
- 8:04So if you want to check that out, they can definitely go find that.
- 8:06But there's a lot of cool things that were taken out of Cinder and are being proposed.
- 8:12And I guess that sort of brings us to our main topic for today is imports and this PEP 690
- 8:19that you all have proposed, which I am also excited for.
- 8:22I think imports are one of those things that are a little bit mysterious to people because
- 8:28they have conceptions coming from other languages, especially compiled languages that are very
- 8:32different than what the reality is.
- 8:35So I do want to talk a whole bunch about what you're offering here, what you're proposing
- 8:39here in this lazy imports PEP.
- 8:42But before we do, let's maybe just set the stage with what happens when I write import requests
- 8:49or I write import FastAPI or even something built in like import collections.
- 8:55Who wants to take this one?
- 8:57Tell people what really happens when the import statement runs or is there.
- 9:00There was a time where the import system for Python was written in C.
- 9:05And it was even more mysterious, I think, at that point.
- 9:07And I don't remember when it was, but Brett Cannon rewrote the import system into Python.
- 9:13And then about that time, I sort of went through sort of line by line and tried to understand.
- 9:20I mean, because right, like imports are probably one of the oldest features of Python, right?
- 9:25They've been around so long and there's so many corner cases, right?
- 9:29It's a very complex system and has lots of features, lots of hooks, lots of places where
- 9:34you can hook in your own behavior and really understanding how all of that fits together.
- 9:39I think I probably took a couple of months to sort of walk through the entire system line
- 9:45by line and document.
- 9:46Unfortunately, now, if you go to the language reference guide, I think it goes into all the
- 9:51gory detail about how imports work.
- 9:54Everything from namespace packages to, you know, concrete packages and all the file system
- 9:59hooks and meta path hooks and, you know, blah, blah, blah, blah, blah, right?
- 10:04Yeah, definitely a lot going on.
- 10:06I think the key thing, though, that you are hinting at there is this is a runtime type of behavior,
- 10:12right?
- 10:13This is a runtime experience.
- 10:14Carl, you're shaking your head.
- 10:16What do you want to add to this?
- 10:17What Barry was saying here?
- 10:19Well, yeah, I mean, I think what a lot of people don't consciously realize initially
- 10:23about imports is that it's just executing some more code, right?
- 10:26So it's like, you can almost think of imports in Python as like syntax sugar for a function
- 10:31call where the body of the function is the module level code of some module and the return
- 10:36value is the module object that you end up getting back from the import.
- 10:40But what it really is, is just causing some more code to be executed where the result is
- 10:45a module object that has stuff on it that you can use.
- 10:48So, and one of the consequences of that is that literally anything can happen when you
- 10:54import a module.
- 10:55I mean, like Barry was saying, you know, it could go off and talk to the internet.
- 10:59I think people have even written stuff that like automatically goes and finds modules on
- 11:03the internet and downloads them just in time to import them.
- 11:06But like, but yeah, that's the key point is that you don't have install.
- 11:09Let's fix that for you.
- 11:13Yeah.
- 11:13It could be arbitrarily slow.
- 11:15It could fail.
- 11:15It could do anything.
- 11:16Yeah.
- 11:17Yeah.
- 11:17You know, if people have a conception of an import statement being like a using statement
- 11:22in C# or an include statement in C++, that's not, that's kind of effectively the same intent,
- 11:30but the behavior is massively different, right?
- 11:33In C++, it says, here's some symbols that should also be used for compilation.
- 11:37In Python, it's literally saying, let's just execute this file top to bottom.
- 11:42And usually execution means define a function, define a function, define a local variable,
- 11:46define a class.
- 11:46But it could mean run some random thing, search the file system, all sorts of stuff.
- 11:52And it leads to things like this, the if dunder name equal dunder main, right?
- 11:59Yeah.
- 11:59This is a big confusion that people run into.
- 12:03Why is this weird thing in Python?
- 12:05Why do they recommend it, right?
- 12:07And it's just because like when you do an import statement, it just runs top to bottom.
- 12:11And if you put behavior in there, well, that behavior happens, right?
- 12:14So here's your way to sort of skip that.
- 12:16Just as a sidebar, you all have been involved for a long time.
- 12:19Like, should Python have had a deaf main sort of entry point thing like so many languages have?
- 12:26I'm not saying it should or shouldn't.
- 12:28I just want to hear your thoughts on this.
- 12:30I think this is just one of those, you know, quirky things about the,
- 12:33not even really even about the language.
- 12:35It's just a quirky thing about the Python, you know, the way you use Python.
- 12:39And to me, it's like one of those things, you learn it and then you just use it.
- 12:44But actually, I think I tend to use this much, much less now,
- 12:48now that we have things like packages and entry points and things like that.
- 12:52To me, you know, I almost am defining a main function.
- 12:55And then in my package metadata, I say, well, there's my entry point.
- 12:59And the packaging system just does it magically.
- 13:02So this is kind of a convenience.
- 13:04And I don't think you really actually run into it as often nowadays as you probably did,
- 13:10you know, years ago.
- 13:11Sure.
- 13:11All my apps that are supposed to be run directly like that, they all have a def main somewhere.
- 13:16And then this just calls the main with this symbol here.
- 13:19Right.
- 13:20Right.
- 13:20Yeah.
- 13:20Herman, what do you think?
- 13:21Yeah.
- 13:21I totally agree.
- 13:22And it's probably not something that we should be using as much right now.
- 13:27Yeah.
- 13:27Sure.
- 13:27Of course, the really interesting thing here, right?
- 13:29Is that it's Dunderne.
- 13:31Right.
- 13:32Like that's a deeper concept about Python that you should really understand is that modules
- 13:38are objects and they have this attribute called Dunder name.
- 13:42And that Dunder name, that attribute is set to some string.
- 13:46And when you call a, when you not import a file, but call a file using the Python executable,
- 13:54that file gets done, you know, this string Dunder main assigned to that attribute.
- 13:59Right.
- 14:00So.
- 14:00Yeah.
- 14:00Yeah.
- 14:01Kind of like understanding a little deeper about how Python works is really important,
- 14:06I think, to get, to be able to use it effectively.
- 14:08It is.
- 14:08And you hinted on being more idiomatic to get better performance.
- 14:12And I totally agree with you.
- 14:13All right.
- 14:14So now knowing kind of what it means to do an import, let's talk about your PEP.
- 14:19Who wants to introduce the PEP here?
- 14:20Herman, you're number one author here.
- 14:23So how about you go for it?
- 14:24Yeah, sure.
- 14:25Well, we all started long before the PEP.
- 14:28In 2020 is when I joined Meta.
- 14:32It was just one month before the pandemic hit.
- 14:35And so I started working in Instagram code base at the time.
- 14:40But there have been a lot of problems cause a problem is there with the reload speeds in the development server and Instagram.
- 14:46And also another, a ton of other common like too, as well.
- 14:51So what I did is I worked in Instagram code base for a couple of years, trying to fight and touch the startup performance problems that we were in the country all the time.
- 15:01And when you get into code bases, the size of Instagram is, they had a whole bunch of problems that become apparent.
- 15:09One of those is...
- 15:11Yeah, most people don't work at the scale in terms of lines of code or number of servers or anything like that.
- 15:16You're definitely pushing the outer envelope there.
- 15:18Yeah, there are thousands and thousands of modules working here.
- 15:22So one of the problems that start to become a parent is startup speed.
- 15:28The other problem is that refactoring modules becomes really, really hard.
- 15:33So if you try to modify something to get it working better, it suddenly starts getting, you suddenly start getting an import cycles.
- 15:42And all that means when you just live around imports or try to split modules.
- 15:46So it gets really tricky and hard.
- 15:49It's complicated.
- 15:50So the start speed, when you run a module that imports other modules, and these modules start to run, then those in turn import more than modules.
- 16:00And this goes on and on.
- 16:02So all transitive dependencies are involved.
- 16:04Right, right.
- 16:05If you just import one thing, it seems minor.
- 16:08But then that could import two things.
- 16:10And those two things could import four things.
- 16:12And then it just, if you're talking thousands of modules, it can explode.
- 16:16And PEP 8 says, import goes at the top.
- 16:19First thing, right?
- 16:20It's like, just to get started before you can even figure out what your code is going to do.
- 16:24You wouldn't do all the imports, which is the transitive closure of every import, basically, right?
- 16:28Exactly.
- 16:29So it just ends up loading every single module.
- 16:32Nobody is going to be used immediately or it's never going to be used at all.
- 16:37So this was an ever ending battle with the Instagram server.
- 16:42And as soon as I realized that I was doing repetitive work, that was very complex and produced a little, very fragile changes.
- 16:51And that was really hard to maintain.
- 16:53And at the end, it didn't really yield the improvements that we needed.
- 16:57So I thought, unless I set sail to write less imports, that's when we started implementing that.
- 17:04Well, the PEP is when we tried to show to the world what we did and the results that we were having.
- 17:12When we get to the U.S. Python 2020 in Salt Lake City.
- 17:16I was planning to discuss this at the Language Summit.
- 17:19But at the end, Carl ended up giving a really good overview there, explaining what it was.
- 17:25I don't know.
- 17:26Carl, can you add?
- 17:27Yeah, we were, I think, Herman proposed a talk for the Language Summit at this last PyCon 2022 in Salt Lake City for the Language Summit.
- 17:35And there just wasn't space in the schedule.
- 17:37So the Language Summit organizers had to pick some things to leave out.
- 17:40And so they didn't squeeze in lazy imports.
- 17:44But then at the Language Summit, a couple of different people brought up lazy imports that they had heard that we had done this and wanted to know more about it.
- 17:51And there was a lightning talks slot at the end of the Language Summit.
- 17:54So in the middle of the afternoon, sitting there at the Language Summit, I just put together about 10 slides on what lazy imports is and how it works.
- 18:01And I gave a quick lightning talk.
- 18:03And on the way back to my seat from giving the lightning talk, Guido leaned over and said, just write the PEP already.
- 18:10So a little bit of positive encouragement and a nudge.
- 18:15Yeah, that's encouragement.
- 18:16So then Herman was at the sprints.
- 18:18And so the two of us sat down together at the sprints on the first day and said, all right, let's write a PEP.
- 18:21So we put together PEP 690.
- 18:23And he said, hey, oh, Barry's walking by.
- 18:25Grab him.
- 18:27Well, yeah, this is something that's been on my radar at LinkedIn for quite a while, like I said, because we have tons of CLIs right from Python.
- 18:35And I think the thing that, like, this is not the first attempt at lazy imports.
- 18:39Like, you know, there's been lots of different approaches.
- 18:42But I think what really kind of struck, certainly what struck me, and I suspect what struck Guido was the really clever implementation of this particular approach to it.
- 18:52I don't know who came up with that, but whoever did it was like really a stroke of genius.
- 18:56Because it really gives you the transparency that I think you need to make this a success.
- 19:05This is a portion of Talk Python To Me is brought to you by Sentry.
- 19:07How would you like to remove a little stress from your life?
- 19:10Do you worry that users may be encountering errors, slowdowns, or crashes with your app right now?
- 19:16Would you even know it until they sent you that support email?
- 19:19How much better would it be to have the error or performance details immediately sent to you, including the call stack and values of local variables and the active user recorded in the report?
- 19:30With Sentry, this is not only possible, it's simple.
- 19:33In fact, we use Sentry on all the Talk Python web properties.
- 19:37We've actually fixed a bug triggered by a user and had the upgrade ready to roll out as we got the support email.
- 19:43That was a great email to write back.
- 19:45Hey, we already saw your error and have already rolled out the fix.
- 19:49Imagine their surprise.
- 19:50Surprise and delight your users.
- 19:53Create your Sentry account at talkpython.fm/sentry.
- 19:56And if you sign up with the code Talk Python, all one word, it's good for two free months of Sentry's business plan, which will give you up to 20 times as many monthly events as well as other features.
- 20:08Create better software, delight your users, and support the podcast.
- 20:12Visit talkpython.fm/sentry and use the coupon code Talk Python.
- 20:20Maybe Carl or Hermann can talk about that a little bit.
- 20:23Yeah, well, let's first define just like what is the PEP proposing?
- 20:26So we've described traditionally what it means when you say import thing.
- 20:31It executes all the Python.
- 20:33And if there's some inline behaviors, that runs those behaviors.
- 20:36And that all happens at the top.
- 20:37Like, how is this different?
- 20:38What change is this proposing to the CPython runtime?
- 20:42Yeah, I mean, the basic idea is just that when you hit an import statement, they say import foo.
- 20:47Instead of immediately at that point going off and finding the foo module, the source code and executing the entire module top to bottom and doing all that work.
- 20:56And then, of course, all the transitive imports from that and et cetera, et cetera.
- 20:59That all we do when we hit import foo is we basically remember, all right, we have this name foo.
- 21:06It refers to a module somewhere.
- 21:08We're going to put off the work of figuring out what that module is and actually executing it.
- 21:13And we're just going to remember that whenever foo is used, that means we need to go find out what it is and actually execute it.
- 21:19So then that name foo will just kind of sit there in the global namespace of whichever module imported it.
- 21:25And oftentimes foo won't even be used or referenced anywhere in the module body of the module that imported it.
- 21:31So we can go through the whole way importing that module and foo just continues to sit there as kind of this deferred pending import.
- 21:38And then later at runtime, maybe somebody calls a function from our module.
- 21:42And within that function, we have like we have a call to foo.bar or something like that, a reference to some attribute of the module.
- 21:49And at that moment, the first time we actually at runtime run into a reference to the name foo, that's the moment when we'll suddenly say, OK, hold everything.
- 21:59We need to go off, figure out what foo is, import it.
- 22:01And now we actually have the proper foo module.
- 22:04And now we can go ahead and figure out what foo.bar is and move on.
- 22:07So that's kind of the essence of PEP690 is to try to do that.
- 22:10Defer imports until the moment when they're first referenced, but try to do it transparently.
- 22:15So that is as much as possible, apart from side effects of the import itself, you really can't tell the difference in your code that the import was delayed.
- 22:25Right. The runtime behavior might be a little bit different, ideally faster and using less memory, which would be great.
- 22:31But other than that, your code shouldn't, but maybe italics shouldn't know the difference.
- 22:38Right. If you're doing coding styles and good patterns, basically not creating side effects during imports, you shouldn't be able to tell the difference.
- 22:47Right. And so if you've got, say, a function that uses JSON parsing, but that only periodically gets called and under some pass.
- 22:55Right. Like you could avoid import JSON effectively unless you need that bit of functionality.
- 23:00And for larger projects that can really cascade. Right.
- 23:03Right. That's the whole idea. So if you think of like a command line program that maybe has like 10 subcommands. Right.
- 23:10And each of those subcommands might do something fairly different and they might have very different dependencies.
- 23:16So on any given time that you run that command line program, if you're only using one subcommand, you don't actually need any of the dependencies of the other nine subcommands.
- 23:24So with lazy imports, you can avoid, you can basically pay for what you use every time you run a program and only pay for what you use.
- 23:31Yeah. I really like the idea. And the transparent aspect of it is, and what Barry was fond of, is that we write code the way we traditionally wrote.
- 23:40We write import requests or import JSON or whatever at the top. And it's up to a special dictionary that replaces a standard dictionary that holds the globals.
- 23:51It says when you access one of these things, if it's not yet materialized and really imported, go do that and then hand it off.
- 23:57Otherwise, just hand off the module. Right. Something like that.
- 24:01Yeah. I think you put it really well.
- 24:02Thanks.
- 24:03It's actually a standard dictionary for the module, but it's just a specialized lookup function, essentially.
- 24:09Got it.
- 24:09Right. So when that deferred object gets installed into the module's dictionary, and this is, I think it's really key because at the point at which that the dictionary lookup function finds this deferred object, that's when the object is resolved.
- 24:24And what that means is that at the Python level, and even if you're an extension writer accessing the module's dictionary, you never see those deferred objects.
- 24:35So they're completely hidden both from the C extension author and Python developer.
- 24:41It's just completely bad. And that's where the transparency really shines.
- 24:45That's where, yeah, because if you're going to force a new programming model onto people, all of a sudden they're going to not like it.
- 24:51And we saw how easy that was to go from two to three. Right. So let's not try that again.
- 24:58Oh, it was so easy. I got this before we get further into this. It's worth pointing out that this is in draft status, right?
- 25:04It was created out a month and a week ago. So it's not super old. It's in draft. If it appears, it'll be in 312, probably. What's the status of the PEP? It's basically proposed and under discussion?
- 25:17Yeah. It's currently discussed. Yeah.
- 25:19I think I went and looked recently and saw that in the, in discuss.python.org in the PEPs category. I think the PEP 690 thread has more posts than any other thread there.
- 25:30So it's been.
- 25:31Okay. That's exciting.
- 25:32It's been thoroughly discussed. But at this point, I think to some extent, the discussion is on hold while we work on getting an implementation against the Python main branch.
- 25:42Cause our implementation in Cinder, Cinder is unfortunately still based on Python 3.8. We're currently working on upgrading it to 3.10, but there's some changes in the underlying dictionary and other things between 3.8 and now 3.12 alpha.
- 25:56So the implementation needs some, some reworking and we need to get that available for people to look at and play with to really move to the next stage in discussion.
- 26:05Yeah. Just a side note. So with projects like Cinder and stuff, it's based on 3.8, which is great. There's a lot of good features.
- 26:11I mean, basically three, six and beyond you get f-strings, you get async and away, you get a lot of amazing stuff there, but the shift from 10 to 11, there's a big performance boost.
- 26:21It's sort of coming along there. Are you guys looking to sort of bring all of this stuff into 11 as sort of a stable point or what's the story there?
- 26:30For Cinder in general?
- 26:31Yeah.
- 26:32Yeah.
- 26:32Yeah. So I mean, we're currently upgrading to 3.10 just to go two versions at a time instead of kind of leap three versions in one bound.
- 26:42And also because as you said, there's a lot of changes between 3.10 and 3.11. So we want to kind of isolate those and get 3.10 stable first and get it in production for Instagram and everything.
- 26:52So that's our current target. And then once that's done, we'll probably look at 3.12 next.
- 26:57Sure.
- 26:57We do want to bring Cinder up to date. And also we're really looking at trying to upstream a lot of the things that are in Cinder so that more people can benefit from them.
- 27:07And to reduce the amount of work we have to do to be constantly rebasing all of our stuff on newer versions of Python.
- 27:12So our goal, hopefully, is that lazy imports.
- 27:14Sure. Everything that you get accepted is just one fewer thing you have to maintain. You can kick it to Barry. Let Barry do it.
- 27:20That's right.
- 27:21Well, I mean, we hope to continue to help maintain these things upstream too.
- 27:26Yes, of course. Yeah, of course. But if you can make it part of the broader community thing, it's no longer your team. It's the community's benefit.
- 27:33Okay. Let's talk a little bit about some of the different forms of imports and how they affect this.
- 27:39Because out in the audience, Hybrid Robotics asks, when you do from library import function, does this really save memory?
- 27:46I think that maybe sets the stage for talking about when there's different styles of imports we can do.
- 27:52Obviously, we can just do import library. We can do from library import function or import star, all these different things.
- 27:59And there's rules in the PEP about how that controls the laziness or the alternative.
- 28:04I guess the current default way is called eager loading or eager imports, right?
- 28:08I think it's really good that Hybrid Robotics brought up this question of from library import function, because that's actually a key way that PEP 690 is different from the existing ways of doing lazy imports.
- 28:18So there are existing things out there. There's a lazy import loader in the standard library.
- 28:23And there's something called demand import on the package index that came out of Mercurial.
- 28:27And all of these things take the approach of having a custom module object.
- 28:31Right.
- 28:32That when you do a get attribute on it, it has a dunder git adder or dunder get attribute implementation that waits for an attribute access and then goes out and does the import.
- 28:41And that works for import foo, but it doesn't make from foo import bar lazy because from foo import bar gets the foo module and then you immediately access the bar attribute on it.
- 28:53And so if you're using this lazy module object style, then effectively it's just eager because you get the attribute off it right away and that makes the import happen.
- 29:01And the difference with PEP 690 is that with from foo import bar, we just stick a lazy object into the namespace of the importing module under the name bar instead of under the name foo.
- 29:13But it's still a lazy object and the import still won't happen until something later actually uses the name bar.
- 29:20So even in the case of from foo import bar, we're still able to make it lazy and it still will save memory at least until or unless you actually use the imported thing.
- 29:30Yeah, that's a great summary.
- 29:31I would like to point out maybe just not entirely sure where they're coming from here.
- 29:36So today, if you write from library import function versus just import library or from library import star, you're not really saving any memory.
- 29:44It basically is doing the same thing, right?
- 29:45The module object is created.
- 29:46It's imported.
- 29:47All the stuff is done.
- 29:48It's just what symbols are defined for you, right?
- 29:52It's more of a syntax thing than it is a memory thing right now.
- 29:55Yeah, that's correct.
- 29:56Yeah.
- 29:57But in the thing you're proposing, this will still be the lazy version, which is great.
- 30:01Yes.
- 30:02Yeah.
- 30:02So there's different ways in which we do import.
- 30:06Sometimes people even do imports inside of try blocks.
- 30:10So like try to import this thing.
- 30:11And if it's not there, maybe try to shim it in or report that this module is a dependency or other things.
- 30:18And it's literally the import statement that is supposed to succeed or fail that communicates back whether or not that was okay.
- 30:25Right.
- 30:25And with this lazy version, you're going to change.
- 30:28It's not going to fail within that try block because within the try block, it's going to create a deferred lazy thing.
- 30:35And that'll always work, right?
- 30:36It actually could also fail in certain circumstances.
- 30:39But for the most part, it should just work.
- 30:42If you have an import inside a try block or inside a class or inside a function, all those imports are eager imports.
- 30:49Right.
- 30:49Exactly.
- 30:50So what I was getting at is that you were actually specifying that if there's an import within a try except or within a width block, you're actually not letting that be lazy.
- 31:00You're making them be eager, right?
- 31:01That's right.
- 31:02Yeah, exactly.
- 31:02Although imports inside this important thing are also lazy.
- 31:07So if any of those fail and you are expecting those to fail, it could not throw an exception there in that reason, in that case.
- 31:16Okay.
- 31:16And then also from thing import star has to be eager.
- 31:21Why does that one have to be eager?
- 31:22Yeah, because we don't have the clean names that are being imported.
- 31:26So there's no way to add these lazy objects to these names.
- 31:32So we need to just import everything and see what are the names that are being imported.
- 31:37That's the main reason for it.
- 31:38Yeah.
- 31:39Right.
- 31:39Because when you say star, you don't know what to put into the module's symbol table, right?
- 31:44So you've got to actually do the import to figure out the star.
- 31:49That's pretty interesting.
- 31:50All right.
- 31:50So there's some interesting examples you have in the PEP that people can check out about.
- 31:54Here's sort of a fake slow module that just does time.sleep, but it effectively shows that it could be slow.
- 32:03And you can run it like do an import and it'll run instantly basically because it's not actually, if you're not accessing that module really at that point, it's pretty much instant.
- 32:12I guess one thing to point out here, and this is, I don't know how I feel about this, but maybe we could talk about it a bit.
- 32:19The proposal is that this is not the default behavior for Python indefinitely into the future, that you have to pass a dash L flag to the interpreter or set an environment variable or something along those lines.
- 32:33You want to talk about why make it opt in instead of maybe opt out?
- 32:37I wish it was a default.
- 32:38That's what I wish to.
- 32:40But the thing, the reality is that there are a lot of applications and modules that are using or relying on import side effects.
- 32:49So we can just expect those to be lazy or compatible anytime soon.
- 32:55So you're saying there's a lot of bad code out there.
- 32:56Is that what you're saying?
- 32:57No.
- 32:58No, I'm just teasing.
- 32:59But if it has side effects, right, if it's like, oh, because you imported this, we've initialized the database connection.
- 33:05There's actually some really good discussion on the discourse thread.
- 33:09I feel like this is actually an important aspect of the PEP because one of the things that was sort of pointed out in this discussion is that I both author libraries and I author applications, right?
- 33:23As a library author, I can't really reason about whether I can sort of say, yeah, maybe my library is unsafe for lazy, but I can never really say, you know, assert that my module is safe for laziness and be certain that in all the way that all my downstream consumers are going to use my library, right?
- 33:45That it's always going to be safe for lazy imports.
- 34:15So by using it, I'm a little uncertain about the environment variable, but I feel pretty strongly like the flag, the dash, capital flag.
- 34:24Yeah.
- 34:24It's the responsibility of the person running it, sort of.
- 34:27It's the leap.
- 34:28Yeah.
- 34:28It's the top of the tree.
- 34:32Yeah.
- 34:33Yeah.
- 34:33To give an example of what Barry's talking about is like, I mean, for better or worse, some level of import side effects are just kind of built into Python.
- 34:41Like if you have a module that subclasses a class from another module, you may think that you have a module with no import side effects, but actually importing your module adds something to the Dunder subclasses of the module you inherited from.
- 34:55And so even code that apparently looks very clean and clear of import side effects does technically have some side effects on import.
- 35:05And the real question is, is anybody actually looking at Dunder subclasses on the parent module?
- 35:09And, you know, there's a lot of common library patterns like decorators that when you decorate a function, they register that function to that class and some registry and some other module.
- 35:20So then suddenly again, you have an import side effect.
- 35:22Like Flask or something.
- 35:22Yeah.
- 35:23Right.
- 35:23Yep.
- 35:23Exactly.
- 35:24So you really have to, it really has to be the person writing the application and testing the application.
- 35:29You says, I'm going to try lazy imports.
- 35:32I'm going to see if things work.
- 35:33I know how my dependencies are used.
- 35:35If it works well and all my tests pass, then I can consider just turning this on at that level.
- 35:40Sure.
- 35:41Okay.
- 35:41Interesting.
- 35:42Taking Barry's idea that it's the application owner who should sort of make this decision.
- 35:48What about having some code artifact that allows you to signal that as well?
- 35:53Right.
- 35:53So as I run it, I can control whether or not this happens.
- 35:57But what if I just the very first line of my app.py or whatever it is, I just say import lazy or something like that.
- 36:05And then every subsequent thing from there on behaves that way.
- 36:08That way, if I distribute my app to someone else, I don't have to convince them or teach them about dash L.
- 36:15I can just say, no, just double click this thing or run this.
- 36:18And it'll just, it'll go in a consistent way.
- 36:21As long as you don't have like PTH files that are getting in the way, you know, before your main gets called.
- 36:27Go ahead, Carl.
- 36:29Sorry.
- 36:29Yeah, no, I was just going to say there was a lot of discussion about that in the thread.
- 36:33And there actually is a draft of a heavily revised version of the PEP.
- 36:38For Barry's review, actually.
- 36:39So Barry, you can.
- 36:40Barry, let me throw that up for you.
- 36:42We can go through it.
- 36:43Yeah.
- 36:45One of the changes that is made in that draft is both removing the environment variable because people were concerned about the risk that if somebody just got the idea that, oh, lazy imports makes everything faster, they might try to just set the environment variable in their shell.
- 37:00And then all of the Python programs they run will try to run with lazy imports and might break.
- 37:05And then they're reporting bugs.
- 37:06And that's not a great experience.
- 37:08So we want it to be really limited to an application that's tested with lazy imports.
- 37:11So the latest draft of the PEP removes the environment variable and actually adds exactly what you're talking about, a programmatic way to enable lazy imports for your application in code.
- 37:21What is the code way?
- 37:23Well, I mean, it's just a proposal in my draft PR to the PEP text right now.
- 37:27So we'll see what Barry says about it.
- 37:29Sure.
- 37:29It could well change.
- 37:31I just rubber stamped it.
- 37:33So the reason I ask is there's sometimes certain things you've got to do to, like, tweak the path or something to get imports to work right if you're running from some weird location or something.
- 37:44Think of, like, alembic migrations and stuff like that.
- 37:48But in a lot of the editors and the linter's, they'll whine at you and say, no, no, no, these imports that go below that modification to the path statement, they go above it.
- 37:58Like, no, the whole point of the thing above it is so the things below it don't fail.
- 38:01Right.
- 38:02Is there, like, whatever it is, I just want to put in a little hint.
- 38:06Like, if you could make the editors not complain that the stuff below it should go above it because the stuff below it is controlled by the stuff above it.
- 38:14You know what I mean?
- 38:14Yeah, the current proposal, I don't think, I mean, I suppose if it becomes merged, the linters and such could special case it.
- 38:21I think hopefully that's not too huge of an issue because the idea is, I mean, you potentially have a large application and this would occur, like, in one main module, right?
- 38:29You would just put like that.
- 38:30Call this function.
- 38:31Right.
- 38:31You put the hash, ignore, and then you're good to go.
- 38:33Right.
- 38:34Got it.
- 38:34Okay, cool.
- 38:35Let's go talk about some benefits here.
- 38:37So, in terms of performance, so it says it's already been demonstrated for startup time improvements of 70% and memory reduction of real-world CLIs by 40%.
- 38:50Those are not joking around.
- 38:51This is not, like, playing at the edges of performance changes.
- 38:54This is significant.
- 38:55So, are those numbers from what you're doing with Instagram or other tools that you tested it on or something like that?
- 39:02These are numbers from Instagram, Instagram server, and also I love command line tools that we use inside Meta.
- 39:09So, yeah, these are real numbers.
- 39:11It's about 70%.
- 39:14Sometimes we've seen 50% improvement in startup speed.
- 39:17Memory is also up to 40%.
- 39:20We've seen 20%.
- 39:21Right.
- 39:22These are upper bounds, of course.
- 39:23Sure.
- 39:24But what I think is good about that is it's not, you know, sometimes people say, well, let's see how fast Python is.
- 39:29I'm going to do a wild true loop and see how many times I can increment a number and compare that to doing that and see, like, okay, nobody does this and they don't really care about how fast.
- 39:39Like, how do real apps behave?
- 39:40How do real?
- 39:41And so, this is you taking the stuff that you all work with day to day and trying to make it faster and getting significant benefits from it.
- 39:48Not weird little edge case benchmarks.
- 39:50Yeah, I think an important thing to note there that Hermann mentioned is that this isn't just one code base.
- 39:54So, you know, we've seen this as repeatable scale of improvement across a variety of different tools.
- 40:00In fact, recently, we've started to see we have a lot of data science people and researchers who use a lot of Jupyter notebooks.
- 40:08And they've started to really quickly pick up Jupyter notebooks kernels based on Cinder with lazy imports enabled because they're seeing similar startup time and memory use numbers for their Jupyter notebooks.
- 40:20So, like, across a fairly wide range of use cases and types of programs, we are seeing these kinds of numbers as consistently repeatable.
- 40:27Yeah, that's interesting to the data science side.
- 40:29A lot of those libraries are pretty large.
- 40:31And so, I suspect that that's probably pretty valuable.
- 40:34So, one of the things you all talk about is that this proposal also will eliminate, what would you call it, like, false import cycles?
- 40:42I don't know.
- 40:43Do you want to talk about this cycle benefit that we might get here?
- 40:47Yeah.
- 40:47Throw it out to all of you.
- 40:48Whoever wants to grab it.
- 40:49I didn't.
- 40:49Can try to say something about the import cycles.
- 40:51When you have imports at the top of the module, and you're not using these imports, and some of the imports that you are declaring there are importing something on the end to us.
- 41:02At some point, it's importing the first module.
- 41:06Then you have a cycle, right?
- 41:07So, if one of these imports is not actually being used, and it's being deferred to a use case where it's only resolved inside a function,
- 41:18further down, which is not being immediately called, then we won't have these cycles.
- 41:24And then a lot of times when we have this kind of imports that are declared on the top of the modules, because
- 41:32But it hates this that is recommended to have all imports in the top of the module.
- 41:37And so people just start putting imports there because it's cleaner and looks better, but
- 41:43it needs to stop provoking these, causing these import cycles.
- 41:48Nice.
- 41:49So hopefully this will solve some of those issues.
- 41:52I know when I first got into Python, I didn't understand why there wasn't a better way out
- 41:57of like sharing code in a bi-directional way.
- 42:01It was really, it took a lot of thinking like, okay, how can I structure my code into different
- 42:06files that don't feel like it's all just went in one file and yet allow me to reference it?
- 42:12Like, for example, if I've got one class and it works with another and it has a function
- 42:17that returns one type of it, but the other one might have a field, which is one of those.
- 42:20And you want to do a type declaration of saying which one is which, or you need to create the
- 42:24call initializer of one or something.
- 42:26Those kinds of bi-directional relationships are hard to model.
- 42:30And it sounds like this doesn't really address or fix or change those in any significant
- 42:34way.
- 42:35But the other ones just about the timing can go away, right?
- 42:38The only import cycles that lazy imports don't fix are the ones where basically it would be
- 42:44a cycle, even if you had it in the same module, like where you're literally using names in a
- 42:50bi-directional way at module level.
- 42:53And so there's no way you could order them even within one module and have it work.
- 42:57And so essentially forward references, those kinds of cycles, the lazy imports doesn't fix.
- 43:00But really any other kind of cycle or anywhere in the cycle, one of the uses is inside a function.
- 43:06All of those are taken care of.
- 43:08And so even for the type annotation ones, if you use from future import annotations, PEP 563,
- 43:15or another proposal, PEP 649, anything that makes the type annotations also lazily evaluated,
- 43:21so they aren't eagerly evaluated at import time, then all of a sudden your cycles went with that
- 43:26plus lazy imports.
- 43:27Then all the cycle problems with type annotations also just disappear.
- 43:31I was just going to say, I think one of the interesting things that I think it was Carl
- 43:34pointed out when we were talking about this is that if you've got the converse is right,
- 43:38if you've got an application or something that's using these lazy imports, and then you turn
- 43:43them off, you might be hit with a bunch of cycles that were sort of, you know, hidden from
- 43:50you because of the lazy feature, right?
- 43:51So you have to be a little bit careful about engaging with lazy imports and then turning them
- 43:57off.
- 43:57Right.
- 43:58Getting everything eager.
- 43:59So it's just one of those things to watch out for.
- 44:01Oh, interesting.
- 44:01Yeah.
- 44:02If you're doing it by running it with the run flag, you could be effectively hiding a runtime
- 44:07error that someone else would hit if they ran it without.
- 44:10Yeah.
- 44:10Right.
- 44:10Kind of back to my like, could the code define this instead of a runtime flag?
- 44:14So it's like absolutely consistent.
- 44:16Yeah.
- 44:16Let's talk about debuggability a little bit.
- 44:19So normally when you have an exception, if I import thing and there's a problem importing that
- 44:24thing, I'll get an exception on the line that the import did.
- 44:27But with this lazy thing, it'll be the import error will occur where the first attempt to
- 44:33touch it happens.
- 44:35Right.
- 44:36But you all do some work to figure out and sort of report back.
- 44:39the error came from where the original import statement was, right?
- 44:42Yes.
- 44:43The error should be reported where the import is being declared so that it's easier to do
- 44:47But this can also produce import error and send anywhere.
- 44:51So the other thing that we are thinking about adding to this implementation is to have an error wrapper around the real error that is being thrown.
- 45:02So we can easily know that it's just an import error coming from a lazy import.
- 45:08Yeah.
- 45:08It could theoretically, I guess, get caught in a situation where people would have not expected it.
- 45:14Right.
- 45:14It could have a overly aggressive try accept block.
- 45:18There's like, well, there's only two types of exceptions that come out of here possibly ever.
- 45:22And either of them, I'm going to handle it in this case.
- 45:25Well, now here's a third.
- 45:26Surprise.
- 45:27Yeah.
- 45:27Okay.
- 45:28But at least from sort of figuring out where the error came from, I guess you guys, what do you call it?
- 45:33Deferred exceptions is what you actually called that, right?
- 45:36Right.
- 45:36So there's a couple of code examples in here.
- 45:39And I'm going to kind of flip through here and check it out.
- 45:42You also have some code APIs.
- 45:43I talked about my wish for some code thing to declare laziness, I guess, is the way to put it.
- 45:48But different things happen.
- 45:50Like if you do the import within a try block, that forces them to be eager.
- 45:54But you also have defined this eager imports context manager, sort of.
- 45:59That will force the imports to be eager, right?
- 46:02And I say sort of because it's not actually the eager imports thing.
- 46:05It's the width block.
- 46:06Whatever you put in there, if you do an import in it, is what's going to trigger it, right?
- 46:10Yeah.
- 46:10It doesn't matter.
- 46:11Yeah.
- 46:11And then the third way is you can import set eager imports and actually pass like namespace names in there.
- 46:19Because one of the problems is I'm going to import a thing that's a package whose code I don't control.
- 46:25And I need it to, for one particular thing, eagerly import that, right?
- 46:29So you kind of have to force it down the line where it's out of the chain of control there.
- 46:33So you can sort of set like, I want to do FastAPI dot whatever, like exceptions or whatever's in there.
- 46:40I want to make sure that that eager loads, even though I don't control FastAPI, right?
- 46:45So you want to talk about some of these code tricks that you have here?
- 46:48Yeah.
- 46:48Or tools, I guess is a better word.
- 46:50Yeah.
- 46:50Let's say the eager imports is just for opting out certain modules.
- 46:54Application owners should be the ones adding the incompatible libraries here if they find or figure out that they aren't playing well with lazy imports.
- 47:04Yeah.
- 47:04So if I write a library and I see that my sub module cannot deal with being lazy, I could put this in my code to avoid, no matter what people set for the runtime flag, I could avoid that problem for my library, right?
- 47:17Yeah, exactly.
- 47:18So you can always try first and if you're the application owner and you know exactly what you need to do this application for, to work, you can try it in modules.
- 47:28And a lot of the libraries just work out of the box.
- 47:31So you don't need to do anything.
- 47:33There are some, some libraries that don't work.
- 47:36And if you can make those work in some other way, you can then add these as eager imports.
- 47:42What's the, I don't know if it's a lazy imports in those libraries.
- 47:46Yeah.
- 47:46Yeah.
- 47:47These are really interesting to see here.
- 47:49Like you can even pass a callback that will be handed a module name and it can, it can decide.
- 47:55You could say, I don't want to just say all the names that are of the sub module, but just anything that matches this pattern.
- 48:01Let's just tell it.
- 48:03We want to eagerly import that.
- 48:05Yeah.
- 48:05Yeah.
- 48:05Yeah.
- 48:05Yeah.
- 48:06It looks nice.
- 48:06I like it.
- 48:07There's a, another question from audience back to a code question and explicit opt-in is a hybrid robotics.
- 48:15Also asked.
- 48:15I really liked the idea of import lazy or lazy import library or something like that to be explicit about it.
- 48:21And you all actually specifically addressed whether or not there should be some syntax code that makes this happen instead of changing the default one.
- 48:29Right.
- 48:30What's the thoughts there?
- 48:31I think generally we're not opposed to the idea of syntax for lazy imports.
- 48:37The kinds of like memory and startup time wins that we've seen really depend on very broad application of lazy imports with just very narrowly targeted opt-outs.
- 48:49That's what you need in order to really get to a situation where you're actually paying for what you use in a robust way where you're not in a situation where you just accidentally add one import in one place.
- 48:59And all of a sudden all your gains just disappear like that.
- 49:02If it's really across the code base, then it's very robust startup time and memory wins where you add one import.
- 49:08And while you might pay for a little more, but you're not going to suddenly start paying 100% of the cost again.
- 49:13It feels like adding new syntax is a much bigger hurdle in terms of the steering council and having to change the Python grammar and all of that.
- 49:22And when the syntax, the per import syntax isn't really even useful in gaining the wins that are the primary motivation for the PEP, then it doesn't feel like a good trade-off to add that to the PEP.
- 49:36Sure.
- 49:36Yeah.
- 49:36I think I agree with that.
- 49:37That seems pretty reasonable to me.
- 49:38What about the reverse?
- 49:40What about if you, instead of doing something like this, where you say, I'm going to force these to be, I'm going to run some code to make these modules eager.
- 49:48What if as a library author, I could write eager import my thing or something along those lines.
- 49:55Now, I really don't want to see more syntax in Python.
- 49:57There was a huge battle over whether a colon goes by an equal sign.
- 50:01So I'm not necessarily suggesting that we should do this.
- 50:04I would say there's nothing necessarily wrong with that.
- 50:07It's more just that adding new syntax is a higher bar and maybe we should get some experience.
- 50:11When the same thing is easily possible with existing syntax, like a context manager, we may as well get some experience with the future in a less invasive way before we go adding syntax.
- 50:21Right.
- 50:21If you see so many people using it and benefiting from it, then you could consider it.
- 50:26I mean, one example of that is like 3.4 to 3.5 when there was asyncio introduced and then there was async and await introduced on top of that.
- 50:34Right.
- 50:34Even things like property, right?
- 50:36Like the property decorator was, you know, a feature that was available for the decorator syntax was added.
- 50:43So it's a tried and true strategy for Python.
- 50:47Let's get experience with the feature and then we can make adjustments and syntax to make it prettier, you know, down the road.
- 50:53Yeah, that's a good path.
- 50:56Awesome.
- 50:56All right.
- 50:57Well, really, really good work on this, you guys.
- 51:00This is exciting.
- 51:02I would like to see the status change from draft to something further.
- 51:06I guess I have to go do something after this chat.
- 51:11Perhaps so.
- 51:12Perhaps.
- 51:12Awesome.
- 51:13But now people know about the conversation much more broadly and maybe we'll get some more, even more comments on the discourse thread there.
- 51:21Let's maybe wrap that up because I think we're about out of time.
- 51:24But before I let you all out of here, you've got the two questions to quickly answer since there's three of you.
- 51:29Barry, if you're going to write some code, what editor are you using these days?
- 51:32It's always going to be Emacs for me.
- 51:34I know.
- 51:35You know, it's funny because Brett works at Microsoft.
- 51:38And so, you know, LinkedIn and Microsoft, we share.
- 51:40He has something to do with some editor.
- 51:41I think people, a few people may have heard of him or something.
- 51:43Yeah.
- 51:45And I keep telling Brett, I want to, I want to, you know, if I was starting today, I would probably, yes, Emacs is just kind of deeply in my bones.
- 51:53Got it.
- 51:54German, how about you?
- 51:55I used to use Sublime Text, even though it didn't have AutoComplete.
- 52:01So I added some AutoComplete from porting, Komodo IDE Editor, AutoComplete to Sublime Text.
- 52:10But now that it's in meta, I'm using VS Code.
- 52:12And also being when I'm in the terminal.
- 52:15Right on.
- 52:16Carl?
- 52:16Yeah, I used to be an Emacs user.
- 52:18I mentioned that's how Barry and I very first connected back at PyCon 2008.
- 52:22But I have switched to VS Code.
- 52:25There's a lot of integrations with VS Code in terms of meta infrastructure and maintaining all that stuff myself for Emacs just became more of a hassle than I wanted to pay.
- 52:35So I've switched to two jobs.
- 52:36One was enough.
- 52:37Right.
- 52:38All right.
- 52:40And then notable PyPI package, something that you think is pretty cool you just want to give a shout out to, popular or not.
- 52:46Go in reverse order.
- 52:47Carl, how about you?
- 52:48Well, I guess I'll give a shout out to something that I use in all of my projects, which is, I guess, depending on the project, either Pyre or mypy.
- 52:55I'm a big fan of type checking my Python codes.
- 52:58Yeah, fantastic.
- 52:58German?
- 52:59Yeah, well, Pyre is pretty good.
- 53:01Oh, I don't know.
- 53:02And microsort, which sorts your imports at the top of the file.
- 53:07So it's really useful.
- 53:09If there's an import syntax that makes all the other ones lazy, all these tools are going to have to learn about, well, this one doesn't go before the other.
- 53:16Or you could give it something like A, A, A, A, A, A, A, lazy.
- 53:19I guess.
- 53:23All right, Barry, how about you?
- 53:27Notable package?
- 53:28For me, it's a PDM, which is a package manager and sort of a build backend.
- 53:33I went through an exercise a couple of months ago where I just was finally wanting to get rid of all my setup.pies and setup.cfgs and just fully embrace pyproject.toml and see how far it could go.
- 53:45And I was actually pretty happy with being able to get rid of both of those legacy packaging files.
- 53:52So I tried a bunch of the different package managers and I really liked PDM.
- 53:56So I kind of, you know, settled on that one for my personal stuff.
- 53:59Yeah, fantastic.
- 54:00All right.
- 54:01Well, final call to action.
- 54:02People want to maybe have their thoughts heard on this.
- 54:05What do they do?
- 54:05I guess the discourse thread.
- 54:07Yeah.
- 54:07Discussed up.
- 54:08Python.org.
- 54:09Look for the PEPS category and look for PEPS 690.
- 54:12Yeah.
- 54:12Cool.
- 54:12You can love it or not love it or stuff like that.
- 54:15There's sort of ways to give just a heart feedback as well.
- 54:19So cool.
- 54:20The other thing you can do is pressure the sponsor of the PEPS to stop being so lazy.
- 54:24And that's something.
- 54:26I would find it incorrect if you were not lazy on this particular one.
- 54:30I mean, you got to just swim in that waterfall and see how it feels before you can really make a decision.
- 54:38Right, right, right, right, right, right, right.
- 54:39Awesome.
- 54:41All right.
- 54:41Well, gentlemen, thank you for being here.
- 54:43It's been great having you all on the show.
- 54:45Thanks.
- 54:45You're welcome.
- 54:45Thanks so much, Michael.
- 54:46Thanks for inviting us.
- 54:48Appreciate it.
- 54:48Yeah, you bet.
- 54:49Bye.
- 54:49Bye.
- 54:49Bye.
- 54:49This has been another episode of Talk Python To Me.
- 54:53Thank you to our sponsors.
- 54:55Be sure to check out what they're offering.
- 54:57It really helps support the show.
- 54:58Take some stress out of your life.
- 55:00Get notified immediately about errors and performance issues in your web or mobile applications with Sentry.
- 55:06Just visit talkpython.fm/sentry and get started for free.
- 55:11And be sure to use the promo code TALKPYTHON, all one word.
- 55:15Want to level up your Python?
- 55:17We have one of the largest catalogs of Python video courses over at Talk Python.
- 55:21Our content ranges from true beginners to deeply advanced topics like memory and async.
- 55:26And best of all, there's not a subscription in sight.
- 55:28Check it out for yourself at training.talkpython.fm.
- 55:31Be sure to subscribe to the show.
- 55:33Open your favorite podcast app and search for Python.
- 55:36We should be right at the top.
- 55:38You can also find the iTunes feed at /itunes, the Google Play feed at /play, and the direct RSS feed at /rss on talkpython.fm.
- 55:48We're live streaming most of our recordings these days.
- 55:50If you want to be part of the show and have your comments featured on the air, be sure to subscribe to our YouTube channel at talkpython.fm/youtube.
- 55:58This is your host, Michael Kennedy.
- 56:00Thanks so much for listening.
- 56:01I really appreciate it.
- 56:02Now get out there and write some Python code.
- 56:04I really appreciate it.