Latest / Talk Python To Me / #172: Nuitka: A full Python compiler
Transcript
- 0:00Quick, name some ways to make your Python code faster.
- 0:02Did you think of PyPy, the JIT compiled version of Python?
- 0:06Maybe some async and await parallelism?
- 0:08How about Cython, where you write in a Python-esque language that compiles to machine instructions?
- 0:13Well, I'm here to add a new one to your vocabulary, Nutka.
- 0:17Nutka is like Cython in that your Python code is compiled into true machine instructions rather than interpreted.
- 0:25But, unlike Cython, you can take standard Python 3 that runs just in regular old Python, CPython,
- 0:31without changing the syntax at all, and still compile that to machine instructions.
- 0:36And Kai Haien is here to take us on the journey of Nutka, a project he's created and has been overseeing for some time.
- 0:42This is Talk Python To Me, episode 172, recorded July 16, 2018.
- 0:48Welcome to Talk Python To Me, a weekly podcast on Python, the language, the libraries, the ecosystem, and the personalities.
- 1:08This is your host, Michael Kennedy. Follow me on Twitter, where I'm @mkennedy.
- 1:13Keep up with the show and listen to past episodes at talkpython.fm, and follow the show on Twitter via at Talk Python.
- 1:19This episode is brought to you by Cox Automotive and Rollbar.
- 1:23Please check out what they're offering during their segments. It really helps support the show.
- 1:27Hey, everyone. Thanks for tuning in, like always.
- 1:30I have two things I want to share with you real quick before we get to the interview.
- 1:33First, I owe you an apology.
- 1:35You don't realize it yet, but you will pretty soon.
- 1:38When I recorded this, the microphone cable that connects my good microphone, the one I'm talking on now, to my computer, got bumped or something.
- 1:46And then the computer just dropped the microphone and fell back to something terrible, like my iPhone headphones or something like that.
- 1:53Anyway, the audio is not up to where I would like it.
- 1:57It's not terrible. It's somewhat like a lot of my guests, I guess.
- 2:00But it could be better, and I really work hard on that, as some of you know.
- 2:04And this one, it's not up to my standards.
- 2:06So hopefully you enjoy the conversation.
- 2:08You can still hear it just fine.
- 2:09It's just not as smooth and nice as this microphone.
- 2:13So please bear with me.
- 2:14It's still a great conversation and absolutely one worth listening to.
- 2:18Secondly, I just released a new course, and I'm really excited about it.
- 2:22This is one that's been in the works for a really long time.
- 2:25It's called Building Data-Driven Web Apps with Pyramid and SQLAlchemy.
- 2:29And we cover all sorts of cool stuff around building web apps, but also things like Alembic for migrations and unit testing web apps and deploying to Linux,
- 2:38and a whole bunch of things that I think you'll find useful.
- 2:41If that course sounds interesting to you, please check it out at talkpython.fm/pyramid.
- 2:46Have a look through the course page, watch the course intro video, and see what it's all about.
- 2:51Hopefully you love it.
- 2:52I really am glad that I got it out there for everyone who's been waiting for it.
- 2:56All right.
- 2:57Now, with that stuff out of the way, it's time to chat with Kai.
- 3:00Kai, welcome to Talk Python.
- 3:02Yes, hello, Michael.
- 3:03I'm glad to be here.
- 3:04Yeah, it's good to have you here.
- 3:05We've been trying for a while to set this up.
- 3:07We've both been on and off traveling and things like that.
- 3:10But it's great to have you here.
- 3:11And I'm really looking forward to speaking to you about your project and your efforts to make Python faster.
- 3:18Yeah, as you can imagine, I'm very excited.
- 3:21Yeah, it looks like you're having some really great success.
- 3:25So I'm excited to share that with everyone.
- 3:27Let's start, though, with your story.
- 3:30How did you get into programming in Python?
- 3:31Yeah, I started as a kid.
- 3:33I think that was a long time before the Internet.
- 3:37So when I was 11, the first thing I ever saw was C64, Commodore 64, my brother, we brought it home.
- 3:43And I had like one or two days of learning basic on it.
- 3:48And then you went away with it.
- 3:50And I didn't have a computer anymore.
- 3:51So what I did, I was programming on paper.
- 3:54Wow.
- 3:55That's a dedication.
- 3:56Programs in my mind.
- 3:57Yeah.
- 3:57That was bizarre.
- 3:59It was hard.
- 4:00But I suspect that that's actually really good training.
- 4:04Because a lot of people, especially with...
- 4:06The editors weren't that good, but paper is actually a lot more flexible.
- 4:13Yeah, that's probably true, actually.
- 4:14But, you know, just a lot of people, I feel like, kind of just poke at the program when they're new.
- 4:19You know, they'll write something that doesn't work.
- 4:22They're like, well, let me just change it and see if it works now.
- 4:23I'll change it a different way.
- 4:25Like, you don't actually, you know, so deeply, like, think through the work.
- 4:29And if you do it on paper, like, you've got to think it through.
- 4:32Yeah, and I didn't learn everything from my brother.
- 4:35So I wanted to write something, I think, Hangman, something like this.
- 4:40And I came up with that there should be something like a loop.
- 4:45But I didn't know what it is.
- 4:46And so on the schoolyard, I pestered all the kids who I knew were also programming.
- 4:51There were, like, maybe three other guys that I knew of.
- 4:55And I pestered them and asked them questions.
- 4:57And I learned about the Goto statement.
- 4:59These are, like, the early loops.
- 5:01The early unstructured wild days of programming before functions and things like that.
- 5:06It was, like, you were on an island.
- 5:08So the cursor was blinking.
- 5:10And you would figure out everything on your own.
- 5:15And there were barely people to talk to.
- 5:16I also, I grew up in a small village.
- 5:18Went to school in a small city, very small city, 6,000 people maybe.
- 5:22And, yeah, there was, I think in my village there was no other kid who had a computer that could
- 5:31actually do some programming.
- 5:32And I was, at least I wasn't aware.
- 5:36So I was very isolated.
- 5:37Yeah, I think that's one of the bigger differences now that you're connected, right?
- 5:43It also made me self.
- 5:46I don't know.
- 5:47I was autodidactic all my life.
- 5:49That's probably stemming from there.
- 5:53Because later I learned, like, stack overflow programming.
- 5:56You type what you want.
- 5:58You copy, paste your code.
- 6:00You're done.
- 6:00But initially it wasn't like that.
- 6:03So I also recall learning a sampler.
- 6:05So coming from basic, it had these line numbers.
- 6:10And I thought addresses were like line numbers.
- 6:13And I wrote down my program.
- 6:15And when I wanted to insert a statement, I just took a number between two addresses.
- 6:21And, yeah, if you know a sampler, you know that corrupts the program.
- 6:26I didn't get it for a long time, what this was all about.
- 6:30So, yeah.
- 6:31So learning a sampler.
- 6:32But eventually I learned the 68K series of processors.
- 6:37It was almost like a high-level language.
- 6:39The C64, it had no registers.
- 6:43You couldn't learn that.
- 6:45That was too crazy.
- 6:46I couldn't get anything done.
- 6:49I think it couldn't multiply.
- 6:51It was crazy.
- 6:53But this one was actually pretty good.
- 6:56And I learned a sampler in C.
- 6:58Later I did C++ for some real programs.
- 7:02Actually had a day job.
- 7:04And met again with my brother, who was studying mathematics and computer science.
- 7:11And he's pretty much older.
- 7:13He's 13 years older.
- 7:14He learned computers from these, what's it called, with the punch cards.
- 7:19And he told me, learn Pearl.
- 7:23If you know Pearl, you will always be the only guy who can do stuff.
- 7:28And he was right.
- 7:30So Pearl was really my absolutely first love.
- 7:34I had learned a lot of languages until then.
- 7:37But Pearl was, like, yeah, amazing.
- 7:41And I read the book of Larry Wall, who was a linguist, designing a language.
- 7:46And he wrote, or he designed the language in a way that it fits your mind.
- 7:50So you would write what you think, however unstructured that is.
- 7:54So unlike Python, where you are forced in a certain, yeah, outline of a code, you could write unless at the end of statements.
- 8:05You could basically write down as you think, and you would never have to go back.
- 8:11You could always just continue writing.
- 8:13That was, like, a really productive way of programming.
- 8:17Yeah, it's interesting.
- 8:18I haven't done much with Pearl, but that sounds quite interesting.
- 8:21Yeah, and Python was upcoming.
- 8:25But it was very weak in terms of, this is 2002 we're talking.
- 8:31It was very weak in terms of supported stuff.
- 8:35So with Pearl, you had modules for everything, much like with Python today.
- 8:40Nothing can compete with Python anymore.
- 8:42But back then, CPAN was like, if you want to do stuff, it's already there.
- 8:47So why bother with Python, which cannot even send an email?
- 8:52You couldn't get stuff done.
- 8:54But it was much more readable.
- 8:56And, yeah, 16 years ago, when I switched jobs, we were working on a product which had a lot of share scripts.
- 9:05And it was pretty ugly, and we wanted to improve on it.
- 9:10And Pearl was, of course, an idea.
- 9:12But a better idea was to use Python.
- 9:14So I switched to Pearl from that.
- 9:17I've since fallen a bit in love with Python, actually, a lot.
- 9:21But it's not my first love.
- 9:23It's never the same.
- 9:24Yeah, yeah.
- 9:25So Pearl was the first to enable me to do what people, I think, a lot of people perceive Python to be.
- 9:32Right, yeah, that's really cool.
- 9:33And for teamwork, it's absolutely much better.
- 9:36Yeah, for sure.
- 9:37And I think what's really interesting, you brought it up here, often people debate languages on the syntax.
- 9:44You know, like, this syntax is better than that syntax.
- 9:48And what most of the time rules the day is, yeah, but I have all these libraries that actually let me do stuff when I put the syntax in place.
- 9:57Right?
- 9:58And that's so important and often sort of forgotten in these language debates.
- 10:02Yeah, this is, I think Java also has this rich ecosystem.
- 10:06C++ sort of, but not as productive, I think.
- 10:11Yeah.
- 10:11Yeah, getting things done and being quick.
- 10:14That's, for many tasks, it was, with Pearl, I've done things for my J job that were just, yeah, beginning.
- 10:22Yeah, great.
- 10:23Yeah, great.
- 10:23It was like, and Python too.
- 10:27And I think now everybody knows this.
- 10:28Oh, everybody that's using Python, that's pretty much.
- 10:31That is a lot of people today.
- 10:34It's pretty amazing, the growth.
- 10:36So, speaking of your day job, what are you doing these days?
- 10:38Currently, I'm on parrots to leave.
- 10:40So, I have a one and a half years kid now.
- 10:43And there's this regulation in Germany which forces your employer to give you time off when you have kids.
- 10:52And you get paid by the state even for 14 months total, both of us.
- 10:57So, my wife took 12 of them.
- 10:58I took two of them.
- 11:00You get a reduced payment for that.
- 11:02And on top of that, I added four months of unpaid parent to leave so I could focus on newt car.
- 11:11That's what I currently do.
- 11:13I have three times two months to spend on newt car.
- 11:16And I'm at the start of a third chunk of that right now.
- 11:20In reality, that parent to leave, I mean, you're a parent.
- 11:25And, yeah, it's a lot of work to care for a small kid.
- 11:28And especially with my wife, she's a doctor.
- 11:31And I'm very emancipated because for roughly 10 days per month, she's not here for 24 hours.
- 11:40So, actually, I get a fair share of her work there.
- 11:45But when I will return, I will be what I've been for 16 years now.
- 11:51I will be an engineer for air traffic management software.
- 11:53Also did a bit of project management.
- 11:57But mostly, I've been an engineer on this time.
- 12:00That sounds like software that you have to be really careful with.
- 12:03Yes.
- 12:03Yes.
- 12:04That's actually, we review everything.
- 12:07And it's the requirements, the code, tests.
- 12:13Everything gets looked with at least four eyes and goes through several phases.
- 12:20And it's amazing.
- 12:22And I was very lucky that the project that I'm working on, it's very old.
- 12:27Now, is it 30 years now?
- 12:29I think it's getting 30 years old or is already 30 years old.
- 12:33And I was blessed with the opportunity to lead the project to replace the middleware because
- 12:38it was closed source software.
- 12:40And the idea was to be able to distribute it to parts of the world where we didn't or the
- 12:48owner didn't have a license for.
- 12:49And so I got to replace the middleware.
- 12:51And I got to introduce Python in the safety critical software.
- 12:55That was also an amazing experience and a huge success.
- 12:59And it's also a reason why a lot of my day job now is Python.
- 13:03So that's, I'm very proud of that because obviously that's not easy.
- 13:09Java can't go there.
- 13:11Yeah, that's cool.
- 13:12Because of the virtual machine doing its cleanups whenever it wants to.
- 13:18But for Python, we managed.
- 13:20Wow, that's really interesting.
- 13:22I definitely have heard that about the GC languages.
- 13:25The unpredictability of the pauses is just too much sometimes.
- 13:28Yeah.
- 13:29Interesting.
- 13:30Yeah.
- 13:30Python is much more predictable with its garbage collection.
- 13:34And budgeting is actually, can become a problem.
- 13:37Yeah.
- 13:37Threading is also something we're not allowed to do.
- 13:40And so we are using multiple processes.
- 13:45And that fits Python's weaknesses pretty well.
- 13:49That's right.
- 13:50So you have to do it the way that Python has to do it.
- 13:52Perfect.
- 13:53We'll use Python.
- 13:54Yeah.
- 13:54Because that's actually, threading is terrible.
- 13:58I recall writing an editor.
- 14:01And this editor was also a file system.
- 14:03So I would type in my editor and launch the compiler.
- 14:08There was no save.
- 14:09It wasn't necessary.
- 14:10I was just using the file system that was the editor and had a scripting language as well.
- 14:14And these are all working on the same data.
- 14:18And I learned an important lesson from there.
- 14:22You don't do threading.
- 14:23It's terrible.
- 14:24We're locking.
- 14:25And it's such a time killer.
- 14:27And yeah, I'm not a fan of threading.
- 14:31It sounds like it.
- 14:32You know, sometimes, I mean, with modern processors, sometimes it's necessary.
- 14:37But it's, yeah, it's maybe not the first thing to jump to.
- 14:40Yeah.
- 14:40Depending on your problem, you don't have a choice.
- 14:42But when it's about safety, I think a process and a thread is not much of a difference, depending
- 14:49on how you work with it.
- 14:50It's roughly the same.
- 14:52It's just more difficult.
- 14:54Because with threads, you get access easier, but also careless.
- 15:00Yeah, exactly.
- 15:00This portion of Talk Python To Me is brought to you by Cox Automotive.
- 15:06They're leading the way in cutting-edge, industry-changing technology that is transforming the way
- 15:11the world buys, sells, and owns cars.
- 15:13And they're looking for software engineers and technical leaders to help them do just that.
- 15:17Do you hate being stuck in one tech stack?
- 15:19Well, that's not a problem at Cox Automotive.
- 15:21Their developers work across multiple tech stacks and platforms.
- 15:24They give you the room you need to grow your career.
- 15:27Bring your technical skills and coding know-how to Cox Automotive.
- 15:31You'll create real-world solutions to today's business problems alongside some of the best
- 15:36and brightest minds.
- 15:37Are you ready to challenge today and transform tomorrow with Cox Automotive?
- 15:41Go to talkpython.fm/cox, C-O-X.
- 15:45And check out all the exciting positions they have open right now.
- 15:50Speaking of performance, let's talk about your project, Nutka.
- 15:53Yeah, so maybe let's just start with a really quick overview of what it is and then how you got started on it.
- 16:01The first thing is it's a fully compatible Python compiler.
- 16:04So it does everything and it's compatible.
- 16:08So the idea is if you run a program with the standard CPython interpreter or you run it with Nutka, it does the same thing.
- 16:16So that's basically only a clone of CPython that is capable of producing binaries just faster.
- 16:26Yeah, that's really neat.
- 16:27And one of the things that I thought was cool about it is you don't have a separate language, right?
- 16:32It's not like, say, Cython where you write a slight variation of Python that then can do this, right?
- 16:37It's like I could take something I wrote yesterday and just run it through you.
- 16:41That's exactly my point is like you have no lock-in.
- 16:45You can anytime something is behaving strange, you have these other implementations or the other Python implementations and you can switch to them.
- 16:55And it's a drop-in replacement for as long as it works.
- 17:00And when it doesn't, you can use something else.
- 17:03That's the point.
- 17:03And you can, and this is very important, you can drop a million lines of code on it and have it accelerated.
- 17:12That's the important point because for small programs, which you fully write on your own, you can accelerate them manually.
- 17:19But for libraries from third parties that you have no clue about, you cannot just live with any kind of limitations.
- 17:28So a big part of the problem was to get everything working.
- 17:33Yeah, to give people a sense.
- 17:34Like during your EuroPython talk, you showed compiling Mercurial, which is, is it over a million lines of Python?
- 17:43I don't know.
- 17:43It's large though.
- 17:45It's not a million line, I think, but it's a substantial project.
- 17:49I think a million lines and all this.
- 17:51Yeah.
- 17:51Python is not that bad.
- 17:53That's true.
- 17:54It's true.
- 17:54It should be less.
- 17:55But it's a seriously large project.
- 17:57It's not just like, oh, look, I can take this and I can write a calculator, a calculator app.
- 18:03To make no changes, no changes to Mercurial.
- 18:06And actually I was capable of doing this in 2012.
- 18:09This was my first demo when Nutka was more like a feasibility study.
- 18:15Back then I had, it was more like a templating from Python to C++.
- 18:21It was just going to demonstrate that this is achievable.
- 18:25And since then it has evolved into an actual real compiler under the hood, still capable of doing the same things and becoming more compatible.
- 18:35So yes, people are using this in real life for real programs.
- 18:41Obviously, some of the things are not working.
- 18:44But I get a lot of positive feedback on a level of compatibility.
- 18:49Yeah.
- 18:49Yeah.
- 18:49I was always thinking that for such a compiler to be acceptable, it needs to run foreign code and guaranteed to behave the same.
- 19:00And otherwise, you just cannot trust it.
- 19:03So how do you do, I'm probably getting things a little out of order here, but just a moment.
- 19:08How do you ensure compatibility?
- 19:09Like you run the tests that they run against CPython itself or things like that?
- 19:14Mm-hmm.
- 19:14I am taking the CPython test suite and, for example, also the Mercurial test suite and run it with compiled and uncompiled.
- 19:24And it must pass or fail the same way.
- 19:26Actually, the CPython test suite, for me, never really passes all the things.
- 19:32And then I run the CPython 3.6 test suite with 3.5.
- 19:37And then I get a lot of exceptions.
- 19:39So I get extra coverage for error cases and these things.
- 19:44So that's one way of doing it.
- 19:47Obviously, then users report me back with incompatible behaviors that they still encountered.
- 19:54Yeah.
- 19:54Maybe something that wasn't covered in the test, right?
- 19:57Yeah.
- 19:58Sometimes that happens.
- 20:00And often they describe the behavior of things in the test pretty well.
- 20:07And sometimes I just add another test to see what it is.
- 20:11But there's many times there are instances where, for example, running Mercurial tests would misbehave
- 20:18and I would trace it down to an incompatible behavior of NewtGuard.
- 20:23Yeah.
- 20:23This has happened in the past.
- 20:25Yeah.
- 20:25It's cool that you have these large programs that are open source.
- 20:28You can go and you just try them.
- 20:30Actually, I would like to go further because right now running the Mercurial test suite is something I do.
- 20:35And this is all a lot of CPU cycles.
- 20:38And I want to integrate with TOX or these kind of projects and get people to just switch on running their own tests with NewtGuard.
- 20:46And see if I pass as well.
- 20:49That's something I need to work on to get out and get even more coverage.
- 20:54Right.
- 20:54If you could get all these other projects with all of their continuous integration automatically running their tests through your stuff,
- 21:01that would be great.
- 21:02Maybe not automatically, but they have to enable that, I suppose.
- 21:05But they shouldn't just say much more.
- 21:08If you want to run your tests with PyPy, I think it's as simple as saying do it.
- 21:13I'll list PyPy in an enumeration and NewtGuard should also be there.
- 21:17But that's just the plan.
- 21:18Right now I rely on people doing things manually and reporting back.
- 21:25And some people run their test suits with compiled stuff.
- 21:29And I'm still pretty early with integration of pytests, running your tests, the compiled code, and then uncompiled tests with pytests.
- 21:40That's working with some tricks, but it's not documented yet.
- 21:45And it's not complete.
- 21:46There's another field where I want to get more exposure.
- 21:50There is Distoutils integration is something that people have started through pull requests on GitHub.
- 21:56And that's pretty awesome because you don't even have to know how NewtGuard works.
- 22:03You just install NewtGuard, enable a flag, and it outputs a wheel, which is a binary for a given platform instead of a no arch wheel.
- 22:16And that's ridiculously easy to use then for existing projects.
- 22:21Right now it's a manual rerun of what setuppy does that you have to specify on the command line.
- 22:29And that's another field of integration.
- 22:33So it should also be that simple to use.
- 22:36That's also my goal.
- 22:37Yeah, that's really great.
- 22:38The more you can just make it just another command you give things and you don't have to really understand it.
- 22:44That's super cool.
- 22:46So maybe we can start looking at what you built by comparing it against other things people might know.
- 22:52So people might know Cython.
- 22:54Let me see if I can summarize it.
- 22:56I think Cython is a lot more successful in terms of adoption because there are people willing to write this hybrid language code
- 23:06and get the optimization benefits of manual work.
- 23:10And it's useful a lot.
- 23:12And I know Stefan Benel.
- 23:14Actually, I worked with Cython for a while.
- 23:16I was listed as a contributor.
- 23:19But I asked them to remove it since initially I wanted to turn Cython into a compatible Python as well.
- 23:28But this didn't work out.
- 23:32I think it's a pretty good solution for what it does.
- 23:38But I think it's bad for the ecosystem for all the reasons that we said.
- 23:43The IDE integration, the lock-in, you cannot switch.
- 23:47So Cython has a bug.
- 23:49There's no way of comparing to anything else.
- 23:53Right.
- 23:53You're stuck with it.
- 23:54You've got to just work around it somehow.
- 23:56Yes.
- 23:57So I have a lot of respect for Cython.
- 24:01I have.
- 24:01I'm an even bigger fan of PyPy, which I also contributed a patch to.
- 24:07PyPy was our Python specifically.
- 24:10We reduced Python for something which I tried out to accelerate actual code of mine long, long time ago.
- 24:17And it's such an amazing project.
- 24:20And obviously there's very little commonality.
- 24:24It's a totally different approach.
- 24:27And it's a thought.
- 24:30So it's a very active project.
- 24:32I think they've been a lot more successful at getting funding.
- 24:37So I'm not getting that.
- 24:40But I think they got money from the European Union initially.
- 24:43And they also got fundraisers and PSF endorsement and all these things.
- 24:49And very huge benefit is many of the benefits that Newtka also has.
- 24:56It's a drop-in replacement.
- 24:57You don't do anything.
- 24:59It works when it works.
- 25:02I mean, sometimes it doesn't.
- 25:04It requires too much memory or can happen.
- 25:07I'm not so much using it.
- 25:10But I think it's a great alternative or maybe even, I don't know if Newtka does succeed.
- 25:18I think it's a great thing.
- 25:19But PyPy is here today.
- 25:22That's really cool.
- 25:24Yes, Cython to me feels a little bit like inline assembler used to be for C, C++.
- 25:32It's like I've got most of my code the way I like it.
- 25:35But this little part, we've got to make this a lot faster.
- 25:37Let's rewrite it sort of here to be a little bit faster.
- 25:41And so that's Cython.
- 25:43And then PyPy is P-Y-P-Y.
- 25:46The JIT compiled sort of CPython runtime.
- 25:52Mostly compatible alternative to Python.
- 25:55Which sometimes is faster.
- 25:57Sometimes it's not.
- 25:59Pretty interesting project.
- 26:00I think they've made progress with the extension modules.
- 26:03But this was a large holding back factor.
- 26:07I think they might maybe do now PyQt.
- 26:11I'm not so sure.
- 26:13Yeah, I think that's right.
- 26:14They did, yeah.
- 26:14Yeah.
- 26:15Yeah.
- 26:16But with Newtka, I could do all the extension modules.
- 26:20I think we can do some or all now.
- 26:22I'm not so sure what's the current state there.
- 26:24I don't follow it, actually.
- 26:26I've had mixed results with it as well.
- 26:30You know, like, I really think the project is awesome.
- 26:34I'm glad it exists.
- 26:34And I know in some places it makes things a lot faster.
- 26:37But I switched out one of my larger websites to run on top of it.
- 26:41And it did.
- 26:42But it was like two and a half times slower.
- 26:45And I thought, well, that's not helping me.
- 26:47So I guess I'll just switch back to CPython.
- 26:50And I think it was probably the C extensions and the data layer or something.
- 26:54I'm not entirely sure.
- 26:55But there was something compatibility.
- 26:57Yeah.
- 26:57If you're on Django or something, that's really something where I need to go is to get Newtka to work out of a box for Django projects, which have their own mess.
- 27:10It's for manage.py is doing all sorts of nasty things that you cannot know about at compile time.
- 27:19But I think the Django, accelerating Django, even by a bit, will be very welcome to many people.
- 27:26And that's also something somebody should go eventually.
- 27:31But I'm not focusing on that right now.
- 27:34I'm focusing on other optimization.
- 27:35So, I mean, for Newtka, I was like, I was observing the landscape for many years.
- 27:42And all this time, I was thinking, a compiler for Python, that's totally possible.
- 27:50And why is nobody doing it?
- 27:53And that was just, I think, a couple of years that I was observing it and wondering.
- 28:00And I think around the 2.5 timeframe, I thought, I'm going to make a prototype, make a proof of concept and show that it's possible.
- 28:10And that turned out to be pretty much the case because a Python design is very welcoming to be compiled, actually.
- 28:18I mean, it's a trivial, it's a non-trivial task.
- 28:21It's very hard.
- 28:22But you can do it for Python, if anything.
- 28:25So, I have this compiled function type.
- 28:27And there's the uncompiled function type in Python.
- 28:31And all I have to do is for them to behave the same.
- 28:35And then you're in.
- 28:36So, you can have a compiled function.
- 28:38That's basically a lot of how you get to work.
- 28:42And then you don't have bytecode, but you have C code behind it.
- 28:45Yeah.
- 28:46And when the C code compiles to machine instructions, and then you're off to the races.
- 28:49Yes.
- 28:51And the Python engine really doesn't care all that much.
- 28:55Because extension modules are first-class citizens.
- 28:59Right.
- 28:59So, let's talk about the architecture just a little bit.
- 29:02So, the way it works is we take regular straight Python code.
- 29:06We feed it to Nutka.
- 29:08Nutka translates that into, like, a reduced Python.
- 29:13The reduced Python is then translated into C.
- 29:16The C is compiled, basically, to a C extension.
- 29:20And that runs on top of CPython.
- 29:23So, Nutka is not its own special runtime, like, say, PyPy is.
- 29:27It's a thing that...
- 29:29No.
- 29:29No, no.
- 29:29It's a thing that...
- 29:30No.
- 29:30No, no.
- 29:31It's a thing that...
- 29:31Do you have to install the runtime for it?
- 29:33Or does it just create...
- 29:34Like, do you have to install CPython, like, 3.5 in order to run it?
- 29:37How...
- 29:38Has it put together?
- 29:39There's two modes.
- 29:39There's a standalone mode, where you create something which will be self-contained, and then contains Python runtime.
- 29:45And there's also this accelerated mode, and then it just links against a Python installation and loads libPython, like every program that embeds Python needs to do.
- 29:58And that's how it goes.
- 30:02And I try to avoid the C runtime, the Python runtime as much as possible.
- 30:07And that's how I curlerate things.
- 30:09So, not having bytecode, and then having knowledge or static optimizations, trying to avoid to go as much into the Python runtime as possible.
- 30:21It's basically the acceleration.
- 30:24Yeah, but you are still...
- 30:26Like, that C code I talked about being generated in the architecture, that still uses, like, the Py object types and stuff like that, right?
- 30:35It's as if you're basically...
- 30:36Your compiler is writing a C extension from our Python code.
- 30:40Yes.
- 30:40That's true, except for...
- 30:42Did you say our Python?
- 30:43The PyPy...
- 30:45It's not...
- 30:45No, no.
- 30:45Our Python.
- 30:46Like, the Python that I write, I give to Nuka.
- 30:48You write...
- 30:49Yes.
- 30:50Yeah, yeah, yeah.
- 30:50Exactly.
- 30:50Yeah, sorry.
- 30:51Sounds the same, of course.
- 30:53No, our Python would be reduced.
- 30:55Yes, exactly.
- 30:56It takes your Python and turns it into an extension module, and then a very hacky one.
- 31:02It's really nasty.
- 31:04I'm really big friend with the dictionary implementation.
- 31:08I take advantage of all the internal knowledges that I'm not supposed to use.
- 31:14Nice.
- 31:15But that's what a compiler is supposed to do, right?
- 31:17Yes.
- 31:19It's responsibility to do all these nasty things, and yeah.
- 31:24And if you order the Python version, the safer it is.
- 31:27So 2.7 is not going to change a lot.
- 31:29Yeah.
- 31:30So we can...
- 31:31You can be shorter on that, yeah.
- 31:36This portion of Talk Python To Me has been brought to you by Rollbar.
- 31:39One of the frustrating things about being a developer is dealing with errors.
- 31:43Ugh.
- 31:43Relying on users to report errors, digging through log files, trying to debug issues, or getting
- 31:49millions of alerts just flooding your inbox and ruining your day.
- 31:52With Rollbar's full-stack error monitoring, you get the context, insight, and control you
- 31:57need to find and fix bugs faster.
- 31:59Adding Rollbar to your Python app is as easy as pip install Rollbar.
- 32:03You can start tracking production errors and deployments in eight minutes or less.
- 32:07Are you considering self-hosting tools for security or compliance reasons?
- 32:11Then you should really check out Rollbar's compliant SaaS option.
- 32:15Get advanced security features and meet compliance without the hassle of self-hosting, including
- 32:20HIPAA, ISO 27001, Privacy Shield, and more.
- 32:24They'd love to give you a demo.
- 32:26Give Rollbar a try today.
- 32:28Go to talkpython.fm/rollbar and check them out.
- 32:31This is Vitar Askin.
- 32:33So let's talk about compatibility a little bit.
- 32:36So it works on Windows, Linux, and macOS.
- 32:39It works on not just that.
- 32:41It's because it's creating C code.
- 32:45I think it will work on anything that you can work with Python on.
- 32:50That's the idea.
- 32:51I obviously can only test Windows and Linux.
- 32:54It works on Windows and MacOS is working because other people are using it.
- 32:58And sometimes I fix something, but I don't have a macOS machine.
- 33:02And yeah, you made an interesting point around that as well.
- 33:06Like, well, I think iOS and Android probably are also candidates here.
- 33:10Yes, Android.
- 33:11I think people have done Android.
- 33:13Obviously, it has been done.
- 33:17And I think I have even done myself.
- 33:21There's a cross-platform toolkit for...
- 33:25I've done some Android compilations myself.
- 33:28It's an ARM-based Linux.
- 33:30It has a Python and you can...
- 33:32Obviously, the compiling machine might be too slow.
- 33:35That's the limitation there.
- 33:37But in principle, there's nothing which prevents it from working.
- 33:41And I think it has been done occasionally on and off.
- 33:44The practicality is currently just not there.
- 33:48But I think once the speed-ups are increasing, I would expect that people...
- 33:56There's a lot of people currently doing games in Python.
- 33:58I met a couple of those.
- 33:59It's very interesting to have something like NewtGov for these use cases.
- 34:05Right.
- 34:05You mentioned the PyPy folks getting the 2D stuff accelerated and working faster.
- 34:11And that was pretty cool.
- 34:12So...
- 34:13But your project is really right in there as well for making these things go faster.
- 34:18Yes.
- 34:19But it's not happening this year.
- 34:23Yeah.
- 34:23So lots of OSs.
- 34:25Python 2 and Python 3 both?
- 34:27Yes.
- 34:273.7 actually.
- 34:29At the time you're releasing this, it will be working.
- 34:34And 3.2, I just discontinued support for that, mostly because it's impossible to get it running.
- 34:41And 3.3.2, 3.7, and 2.6, 2.7, they all work.
- 34:47In my design, I have what I call these reformulations.
- 34:50I think you can put up a link to these language conversions to make things simpler from my developer menu,
- 34:58which is very instructive, and it explains a lot of things.
- 35:02Actually, to me, this is a baby Python or this commonality Python internal that I'm using.
- 35:11And the with statement, for instance, it's translated into many statements, actually.
- 35:19Or a third statement is just if not condition, race, assertion error with my arguments, these kind of things.
- 35:28And that means that most of the time, the Python versions do not make as much difference as you would think they do.
- 35:36Right.
- 35:37You've got some step that goes, oh, I look at a with statement, I'm going to translate that to something else, regardless of which level.
- 35:44So there's a huge chunk of code dedicated to reformulating the with statement into a series of try-accept-finally stuff,
- 35:53doing lookups of enter and exit, implementing the Python mechanics in explicit terms with temporary variables and so on,
- 36:04which then can be optimized at compile time.
- 36:08Maybe sometimes we know that it's not going to raise an exception and then we can drop this.
- 36:14That's basically the reason why the language versions are not that much of a problem.
- 36:21Yeah.
- 36:22I suspect that the async stuff was more interesting.
- 36:25Oh, this was terrible.
- 36:26And especially imagine our coroutines and async jams.
- 36:30Like, I've seen this being used.
- 36:33I personally never knew why I would use it.
- 36:37Well, so I don't use it.
- 36:40And because it's like you get a lot of disadvantages of reading without the advantages.
- 36:45I'm not so sure why it is good.
- 36:47Well, I was just thinking of you, how difficult that must be to implement in this scenario and your comments in the beginning, how you don't really like them.
- 36:56I had no idea what it is about.
- 36:59It's like I'm trying to find out what it does and use it and the semantics and especially the coroutines, for example,
- 37:08in a minor release, 3.5.2, they changed their mind how they work.
- 37:13And they introduced a compatibility layer.
- 37:17And then in 3.5.2, yeah, it was like a totally new implementation compatible with another one, which is a total mess.
- 37:26And the async generators are taking it to the extreme.
- 37:29And like, you know, when I started Nutka, there was a yield statement.
- 37:35So a generator could yield the execution.
- 37:39There was no return value.
- 37:40And then this got added.
- 37:43Actually, it was through Nutka that I learned that this changed at all.
- 37:48So you can imagine that what happened there is it's amazing.
- 37:54And they have a full team of people implementing this stuff and throwing out a new release.
- 37:59And I get to replicate that.
- 38:01That's basically what happens.
- 38:04And that's one guy against the whole team.
- 38:07And then you try to be faster with your implementation.
- 38:11That's actually ridiculous.
- 38:14But the last release wasn't so bad.
- 38:17It's actually I didn't encounter anything crazy.
- 38:20That's cool.
- 38:21I'm pretty impressed that you got 3.7 going already because that just came out a couple weeks ago.
- 38:27Yeah, yeah.
- 38:28Actually, with 3.6, I was reporting bugs.
- 38:31So I did with the 3.7.0 some bug report now about dictionaries.
- 38:35I was using release candidates and reporting my findings.
- 38:41So I have a couple of tests which demonstrate that Nutka is not misoptimizing certain things badly.
- 38:48And I found out CPython was so Nutka wasn't, but CPython was.
- 38:53And I could turn this into reports.
- 38:54And 3.6 was already pretty good at the time it was released.
- 38:58Therefore, but for 3.7, they made a huge change to exception handling.
- 39:03Exception handling is also absolutely terrible.
- 39:06I think in Python 2, it had pretty crazy semantics where a frame had an exception and restored it.
- 39:14And it was terrible in Python 3, they changed it again.
- 39:18And now in 3.7, they changed it yet again, but mostly on the implementation side.
- 39:26So the structures internally, where you store it and so on.
- 39:30This changed.
- 39:31And this prevented me from, without a lot of changes, to compile with Nutka in 3.7.
- 39:36So I'm a bit late, actually.
- 39:37But I normally try to be quick with this because the early adopters will pester me about lack of support for the latest, greatest Python release.
- 39:50Yeah, it sounds like you're pretty much on top of it.
- 39:52That's really good.
- 39:53So one thing that I was thinking about as I was looking at this is what basically can be the output of Nutka is it's like a C extension, right?
- 40:03A compiled C extension.
- 40:04That's one of them.
- 40:05Yeah.
- 40:06So if I have regular Python code that I just want to run, not compiled or anything, just standard, but there's part of my program that I would like to make faster and optimize with what you're doing, I can put those two things together, right?
- 40:21Yes, you can.
- 40:21That's absolutely true.
- 40:23And actually, one of the things I'm aiming at is making bindings an easy task.
- 40:31So my vision of bindings is for you to use C types or something.
- 40:36For the middleware, we use C types to make bindings.
- 40:39So it's implemented in ADA, but you can think of C code.
- 40:43And that's a pretty neat way of doing the bindings.
- 40:46And my idea of this for Nutka to optimize that way and not use C types, but to directly C codes and do bindings like this in a comparable fashion.
- 40:59And what I also want to achieve is that Nutka makes available the original code.
- 41:05So if I use that binding extension then and try to compile a program, I would like for the compilation process to be able to go and inline code from there.
- 41:19So I'm not so sure if I was clear or not.
- 41:22But the idea was right now there's a barrier.
- 41:26So if it's an extension module, it's an extension module.
- 41:30I can't look into PyQt at all if it's created with zip.
- 41:35And I want to replace this with the ability to make a call into a bound C function in my main program.
- 41:45And normally I would use this compiled extension module, compiled with Nutka.
- 41:50And if I compile the program, it would be able to inline that extension module's call.
- 41:55Right.
- 41:56So not just optimizing the Python code you feed it, but actually optimizing the underlying C code that's being used.
- 42:01Because ultimately it gets down to like C on C.
- 42:04Yeah, generate C code for the compile program again.
- 42:08And I think the ecosystem would benefit from having these dual mode codes.
- 42:15Like you have this original Python binding and you have the compiled extension.
- 42:21You can use the compiled extensions where you want.
- 42:24And you can also use the original code if you compile.
- 42:27So that's my vision.
- 42:29And I think that would be healthy for the ecosystem.
- 42:33And that's something that Cython doesn't do.
- 42:36And then it would, I think, be much more attractive to do bindings in pure Python.
- 42:42Yeah, I think that sounds really great.
- 42:44That's awesome.
- 42:45That's my vision.
- 42:47And I think I will be getting there.
- 42:49Yeah, I think you will as well.
- 42:51You definitely got some impressive stuff already working.
- 42:53Let's talk about some of the optimizations.
- 42:55It sounds to me like one of the most important things that you could do in Python is to inline functions.
- 43:01Because functions in Python are almost, I want to say, unreasonably slow.
- 43:05They're like quite, it's actually quite a high penalty to call a function in Python.
- 43:12Just that mechanics of setting up that stack and call and whatever compared to, say, other languages where it's slow.
- 43:19It has an effect, but it's not like, you know, super significant.
- 43:23Yeah, it did a lot of hacks to accelerate functional method codes, actually.
- 43:27And a lot of the acceleration in Utica is coming from being willing to do all kinds of nasty tricks to call functions in a faster way.
- 43:39That's a huge overhead and this inlining that will, of course, make all the difference.
- 43:45But it requires whole program optimization.
- 43:48That's a rather difficult task.
- 43:51So as you know, with Python code, it can change everything behind my back without me noticing.
- 43:56Right.
- 43:57I will always have to do both the things.
- 44:01So I will have to check that it's actually what I'm thinking it is.
- 44:06Much like the PyPy JIT is having guards, like, is it really the same as last time?
- 44:12And is it really what I expect it to be?
- 44:16And then I can be super fast or I need to fall back because something crazy happened behind my back.
- 44:22Right.
- 44:22Like a unit test patch, for example.
- 44:25Yes.
- 44:26That kind of thing will have to work.
- 44:28And then, but that's this duality.
- 44:31It's my vision of how things will then eventually work.
- 44:36But inlining code will definitely do a lot of things.
- 44:40I'm currently working on classes and optimizing the classes and the dictionaries and tracing the values in there.
- 44:47And NUTCA and I hope the next release will be capable of statically optimizing most classes into a simple call to type with a static dictionary.
- 45:01Of stuff.
- 45:02Of stuff.
- 45:02That's the first step, obviously, to understanding types fully, because I will be able to precisely know the dictionaries.
- 45:11Then I have to see through the meta class mechanics and see that they are actually mostly harmless most of the times.
- 45:19And from there, I take it from there.
- 45:22This is a, I think it's a huge undertaking.
- 45:25It's one of the directions that I want to go.
- 45:28So these global program optimizations are one thing.
- 45:31And then locally, for cases where I do know that something is an integer, I want to get to using alternative integers and Python integers or just the C type where possible.
- 45:45That's the direction I intend to work on the next two months.
- 45:49Basically, that is the magic sauce that makes Cython fast is that you explicitly type your stuff and it lets, you know, it just be four bytes on the stack in C rather than all the indirect stuff.
- 46:03Like, well, it could be this reference type.
- 46:06Like, we don't really know what it is.
- 46:07You know, treat it as a full on pie object.
- 46:10Yes.
- 46:10You're working on this as well.
- 46:11Yes.
- 46:11That's crazy.
- 46:12And this is where I think C level performance is possible.
- 46:16And then I have the idea that unlike Cython, I want to make type annotations to that are actually behaving in Python at runtime too.
- 46:28So I would like you to declare that the function takes integer arguments and will raise an exception if it isn't integers.
- 46:37And then I want to have Newt Cassie through that, take these assertions and generate specialized code from there, much like Cython does, but in a lot more complex way and with the benefit of actually enforcing these things at runtime.
- 46:54That's the vision there, which is also a lot of work.
- 46:59You would have to write some decorators, but I think other people can do this.
- 47:04Just today I asked somebody who offered to volunteer if he could do it.
- 47:08That would be great if people joined such efforts because that's all only about CPython, right?
- 47:15You can write this without any knowledge of Newt Cassie.
- 47:19It's just, I want to have a decorator which says, I have to clear this class and now it's frozen.
- 47:25You will not be able to change anything after the fact about this or else you get an exception.
- 47:30And that's a hint to the compiler to take advantage of that for static optimization.
- 47:37Yeah.
- 47:37A little like slots, right?
- 47:39Yeah, exactly.
- 47:40Like slots.
- 47:41But in a more general fashion and enforcing these things.
- 47:47And these kinds of decorators, I think, make all sense.
- 47:52And yeah, this is another avenue where I think Newtcar will also be beneficial to the ecosystem of making it viable.
- 48:02Because what it will do is you slow down your program terribly because it will do all these checks that typically are not useful at runtime if you do with the Python decorators.
- 48:13But then when you accelerate some, it's actually better.
- 48:18And that's the idea.
- 48:20Well, that'll let you claim a much higher performance boost.
- 48:22Look, I ran it on her Newtcar.
- 48:23It was 20 times faster.
- 48:25Just kidding, because it would be slower, right?
- 48:27Yeah.
- 48:28So I don't know if you're getting this, but Newtcar is a crazy compromise-free project.
- 48:33And if it fails, which it probably will, that's why.
- 48:38It's all about trying to do the best thing possible.
- 48:42Yeah, the compromise-free part is what makes it so challenging, right?
- 48:46Yes, it's so challenging, but it's also, yeah, it's rewarding.
- 48:50And everything I've achieved challenge-free from when in 2003 to I made these public releases of Newtcar, it was usable.
- 48:59It was usable from day one.
- 49:01And it has remained usable all this time.
- 49:05And it only became ever usable, more usable.
- 49:09What it didn't become in, I think, like at least two years, it didn't become faster.
- 49:14Because I'm doing these big transformations of internals where, for example, the local dictionary work that I'm doing on classes, class declarations aren't performance critical at all.
- 49:27You run that code once.
- 49:29It's not in a loop.
- 49:30But for scalability, it's hugely important to get this, because if you compile this million line of code and you optimize it better, it's much less code.
- 49:43And for these plans, we really need to understand the global picture there.
- 49:51So I'm spending a lot of time on stuff that doesn't actually improve performance at all most of the time.
- 49:58And I really look forward to finally having fun running benchmarks again, because I really don't enjoy running benchmarks if the numbers are all stacked.
- 50:09Yes.
- 50:10It's sad.
- 50:12It's crazy.
- 50:12And it's totally anti what everybody else has done in the field so far.
- 50:18So there has been compilers from Google.
- 50:21I forgot the name now.
- 50:23But they had their own project.
- 50:25And the first thing they had is incredibly well-numbered benchmarks.
- 50:31And, yeah, but it wasn't doing what it should be doing.
- 50:35I think the unladen swallow.
- 50:38Yeah, yeah, I think you're right.
- 50:40Unladen swallow, I think.
- 50:41It just went away.
- 50:42And it's not sustainable because you can't use it for anything but benchmarks.
- 50:47Right.
- 50:47That's basically the idea.
- 50:50And I'm doing something which can be used outside of benchmarks.
- 50:52But there will always be code which is currently slower and new to curve because I didn't look at it.
- 50:58Or actually CPython has a lot of tricks.
- 51:01I recall that it took me a long time until I was at the point to emulate their in-place assignment tricks.
- 51:09So if you do an in-place assignment to a string, they did some things to avoid allocating a new object unless a reference was held on the outside.
- 51:20Which in many instances makes it incredibly, like infinitely faster than Newtco was.
- 51:27And so I'm behind in some optimizations even.
- 51:31And that's pretty tough.
- 51:35And obviously I would like to have also cool benchmarks.
- 51:39But what I would like to have is also the ability to say, and you can have it too in your program.
- 51:46That's obviously, I don't know.
- 51:48And forever it has felt like it's right around the corner that I can do this now.
- 51:54And then I discover something else that I need to do first.
- 51:58Yeah, that's why I brought up Mercurial.
- 52:00Because that's a pretty serious application to process.
- 52:05Yeah, and just carrying the full weight.
- 52:07So doing all these refactorings.
- 52:10And I'm always doing these refactorings in a non-breaking way.
- 52:13So I try to not strive too far away from a working state in all the changes that I made.
- 52:22So I made gradual changes.
- 52:23Like I said, initially it was more like a templating language.
- 52:28And I turned it into a single state assignment form compiler gradually.
- 52:35One by one, bit by bit.
- 52:37And trusted more here and there.
- 52:41Right now this value tracing is very reliable.
- 52:45But still not used for everything.
- 52:49I think right now the major fact that I'm using it is do I need to check if the value is assigned or not.
- 52:57And that's mostly what it's being used for.
- 52:59And for static optimization.
- 53:01And that's working bug free.
- 53:04But I'm always expanding this.
- 53:07And then I find something which is not yet working.
- 53:11That's the crux of it.
- 53:13Yeah.
- 53:13Well, it sounds like it's getting better and better.
- 53:15And there's a lot of things that you could unlock with it.
- 53:19So speaking of stuff that's faster, stuff that's slower.
- 53:23When should I use this?
- 53:26And maybe when shouldn't I use it?
- 53:28Oh, you shouldn't use it if you don't care about performance.
- 53:31Yeah.
- 53:32Compatibility is just like mostly what you care about.
- 53:35Yeah.
- 53:35Actually, I have this secret pipe dream of being better than PyLint.
- 53:41But that's not.
- 53:42That's a whole other issue.
- 53:44Because my static analysis may uncover things that PyLint wouldn't.
- 53:49The program analysis.
- 53:51And if you don't care about performance.
- 53:54And I think that's roughly 99% of all the people.
- 53:57And you should use it if you are into NumPy and these things.
- 54:04Although I wasn't having discussions with a university.
- 54:08It would take somebody to work on specializing code generation for NumPy.
- 54:14So NumPy is a hugely great scientific library where you would just provide very little Python code on your own.
- 54:22And for you to do something for each cell, for example, that would be bytecode.
- 54:27And it would be massively cool if we could have this little bit compiled.
- 54:33Yeah.
- 54:34And still run it.
- 54:36And I think NumPy would be then practically not entering the Python runtime a lot.
- 54:45And that would be something.
- 54:47But I didn't quite manage to get some university or something involved.
- 54:52So scientific applications and financial applications are also like where you want to do financial stocks, something.
- 55:02You want to buy as fast as possible, make your decisions as fast as possible, real-time applications in Python.
- 55:09All the algorithmic trading stuff, yeah.
- 55:10Some people are crazy enough to do this in Python because of the development turnaround.
- 55:14And then they want to throw something easy on it to get it accelerated.
- 55:20And on another day, they want to change the algorithm simply.
- 55:25And that's the kind of uses.
- 55:28I think to most people that do not care that much about acceleration, some people care about deployment.
- 55:36And there's a standalone mode, especially on Windows.
- 55:40where you do not normally have any Python on an arbitrary user machine and definitely not the version you want to have and definitely not the modules.
- 55:50You can run a newtker and use it to create this distribution folder and send that to people's way and have things work.
- 56:01That's, I think, what a lot of people use it for.
- 56:04I think that it's really excellent.
- 56:05And so basically you compile it down to an exe that does not depend on CPython.
- 56:11It bundles it up to contain that within itself, right?
- 56:14Not on an installation.
- 56:15Yeah.
- 56:17Yes.
- 56:17And yeah, although you could use anaconda python for that too.
- 56:22It's, I think, a convenient package.
- 56:26I think that also a lot of people are using it to hide their source code from people.
- 56:32And that's actually something which I'm, well, that's what compilers allow for.
- 56:37It's not my, it's not my daily joy of being part of depriving people of the ability to change source code.
- 56:46But yeah, that's people's people own their source code.
- 56:50So we can do, they can give it to you or they can't in favor of that.
- 56:55But yeah, that's one other mode of operation, which I think is unfortunately the majority of users, I guess.
- 57:04And it's also causing a lot of trouble because extension modules often do imports of stuff which they don't tell me about.
- 57:10And then they crash when it's not present.
- 57:13And it's sometimes very nice.
- 57:15Yeah, I can imagine.
- 57:16It's tricky.
- 57:17So if I'm using external packages off of PyPI, that's no problem, right?
- 57:23You can deal with that.
- 57:24So if I work with requests, SQLAlchemy, whatever, I can run that through Nuka?
- 57:28That's awesome.
- 57:29Yes, yes.
- 57:30Actually, yeah.
- 57:32It's the out-of-the-box experience.
- 57:34You just arbitrary code.
- 57:36It's supposed to work.
- 57:38I think Django is, if it's some of the really dynamic, crazy stuff, would need a plugin to be created to pass it.
- 57:47Because I think Django does some dynamic imports of stuff.
- 57:51Some people are getting it to work.
- 57:54I don't know.
- 57:55But that takes some modifications.
- 57:58Yeah, sure, sure.
- 57:59Interesting.
- 58:00So this, yeah, the standalone mode is pretty interesting as well.
- 58:03So I think we're getting kind of near the end of our time.
- 58:07So one thing I did want to highlight, I think, it sounds like you're looking for contributors.
- 58:13And there's a lot of places that people can contribute.
- 58:16You talked about writing some standard Python code that then Nuka could use.
- 58:21I'm sure if there was a long list of these are all the optimizations we're looking for.
- 58:25Could anybody who's good at this kind of stuff and see?
- 58:28Could you help here?
- 58:29Things like that.
- 58:31Are you looking for contributors along those lines?
- 58:33Yes, of course I am.
- 58:34I actually have to think if I did, I should have a list of issues on GitHub that are marked as help wanted.
- 58:46And there's a lot of these things.
- 58:50And obviously I could and should create a couple more from these ideas that I just told you about.
- 58:59And that's totally something I should do.
- 59:02I have relatively bad experience with people joining the project because it's tough to get progress.
- 59:10It's also a complex design, not easy to get into.
- 59:16It takes a lot of skill and privacy.
- 59:18And occasionally I get contributors.
- 59:23But I think it's not rewarding enough, I think, for many people, unfortunately.
- 59:30Yeah, it takes a lot of effort to see the rewards through, right?
- 59:32I'm just thinking that there must be many people who are working on compilers and stuff who just left university and are looking for some kind of project.
- 59:41You know, maybe they could jump in, right?
- 59:44Yes, I welcome everybody.
- 59:45But I have to be honest with you.
- 59:47I also don't have time to actually mentor much.
- 59:52I can't guide people through doing things and then they lose interest.
- 59:59That's happened a couple of times.
- 1:00:01So there's a lot of people who want to find out if this is something they would be willing to do.
- 1:00:07And yeah, I have a family, I have a day job, and this is my spare time.
- 1:00:12Right, absolutely.
- 1:00:13It needs a lot of work.
- 1:00:15Communication often takes second place after coding myself.
- 1:00:21Yeah, that's the challenge of doing this as a part-time project, right?
- 1:00:25Yeah, it's totally impossible to keep up with.
- 1:00:28So suppose somebody really wants to get into this and yeah, I cannot respond quick enough sometimes.
- 1:00:37And that's already frustrating.
- 1:00:40Sure.
- 1:00:41I guess people could probably start by watching your EuroPython presentations and then go from there.
- 1:00:46Yeah, yeah.
- 1:00:47Yeah, but also I think what I really would need is somebody with community skills who would be capable of doing a fundraiser for me.
- 1:00:56It's a long-term project and a lot of people have short-term needs.
- 1:01:02I need to get Newtka to a point where people with short-term needs will feel that investing their time into Newtka is worthwhile.
- 1:01:13And then it will be a different story.
- 1:01:15Yeah, but coming back to what I would like to have.
- 1:01:18I would like to have somebody who organizes some fundraiser and does this so I could get time off my day job.
- 1:01:28I work on Newtka and I've invested my own money right now.
- 1:01:32Four months unpaid is a lot of effort.
- 1:01:36I'm buying hardware and so on.
- 1:01:38I'm getting some donations, but it's not enough to buy the hardware that I buy for Newtka.
- 1:01:43And that's also something people could do is to send donations my way.
- 1:01:51But I think a concerted effort that would gain visibility and with a raising goal and me being able to put a couple of months again into Newtka and pushing really forward, that would be great.
- 1:02:05Probably that's something more than I need than actual contributors.
- 1:02:10Because I think I need to reach a breaking point where I have something that is attractive enough for people who have actual problems to just add the bits that they are missing.
- 1:02:22Like at the point where they have a lot of optimization and then they run into some construct which is not properly optimized and then they can hack it.
- 1:02:32And then it is.
- 1:02:33That's a thing for them then.
- 1:02:34Right now, that's not the case.
- 1:02:36Right now, you would have to be somebody with a long term vision and no concrete other problems that require your attention.
- 1:02:44So that's it.
- 1:02:46I think the couple of months sprint really would make a big difference.
- 1:02:50I've seen that make a difference in other projects more than donations or other things as well.
- 1:02:56So certainly that sounds like a good thing.
- 1:02:57All right.
- 1:02:58Kai, before we get out of here, let me ask you the final two questions.
- 1:03:01If you're going to write some Python code, what editor do you use?
- 1:03:05I'm using Eclipse and PyDef specifically.
- 1:03:08I occasionally use VI on the command line just for quickness, but Eclipse and PyDef it is.
- 1:03:15Right on.
- 1:03:16And then just some notable PyPI packages.
- 1:03:19Maybe people haven't heard of them or aren't using them yet.
- 1:03:23Obviously, I have a lot of machines running and I'm using Ansible, which somebody introduced me on a Debian conference.
- 1:03:31I'm forever grateful for the tutorial I got there.
- 1:03:34It's very useful tools like salt, if you know that, Ansible written in Python.
- 1:03:41And you just can easily deploy all your machines in a similar fashion.
- 1:03:47And that's great.
- 1:03:49Nicola is something I'm actually, I forgot my contributor number.
- 1:03:53I might be contributor number five or something or static website generation.
- 1:03:57That's what people are using a lot these days.
- 1:04:01And I really liked the idea and I joined that and I'm using it for my website.
- 1:04:06And it's great.
- 1:04:08And obviously, BuildBot is also a tool I heavily rely on.
- 1:04:12I absolutely despise Jenkins, which I have to use at work.
- 1:04:16The BuildBot is great because you get to write your configuration as Python code.
- 1:04:22Actually, there's no web interface needed to configure stuff.
- 1:04:26You just do your for loops and stuff and everything is consistent, which is great.
- 1:04:30And I think something which should get more exposure is pip-env, which combines the virtues of virtual environments and pip install, making it easy to run stuff.
- 1:04:44I'm not using that myself a lot, but I think it's very notable.
- 1:04:49Yeah, absolutely.
- 1:04:50Absolutely.
- 1:04:51All right, Kai, thank you for being on the show.
- 1:04:53This was a really interesting project that you've been working on a long time.
- 1:04:57And it's definitely a cool exploration of this compiled space.
- 1:05:02And it's its own take.
- 1:05:03And I would like to thank you for hosting me and giving me your opportunity.
- 1:05:08And I hope it wasn't rambling too much.
- 1:05:10It was some interesting stories.
- 1:05:12Thank you.
- 1:05:12And yeah, take care.
- 1:05:14Okay, bye-bye.
- 1:05:15This has been another episode of Talk Python To Me.
- 1:05:19Our guest for this episode is Kai Haian, and it's been brought to you by Cox Automotive and Rollbar.
- 1:05:24Join Cox Automotive and use your technical skills to transform the way the world buys, sells, and owns cars.
- 1:05:31Find an exciting technical position that's right for you at talkpython.fm/cox, C-O-X.
- 1:05:37Rollbar takes the pain out of errors.
- 1:05:40They give you the context and insight you need to quickly locate and fix errors that might have gone unnoticed until your users complain, of course.
- 1:05:48As Talk Python To Me listeners, track a ridiculous number of errors for free at rollbar.com slash Talk Python To Me.
- 1:05:56Want to level up your Python?
- 1:05:57If you're just getting started, try my Python jumpstart by building 10 apps or our brand new 100 days of code in Python.
- 1:06:04And if you're interested in more than one course, be sure to check out the Everything Bundle.
- 1:06:08It's like a subscription that never expires.
- 1:06:10Be sure to subscribe to the show.
- 1:06:12Open your favorite podcatcher and search for Python.
- 1:06:14We should be right at the top.
- 1:06:16You can also find the iTunes feed at /itunes, Google Play feed at /play, and direct RSS feed at /rss on talkpython.fm.
- 1:06:25This is your host, Michael Kennedy.
- 1:06:27Thanks so much for listening.
- 1:06:28I really appreciate it.
- 1:06:29Now get out there and write some Python code.
- 1:06:31I really appreciate it.