Visit our site to listen to past episodes, support the show, and sign up for our mailing list.
Summary
Kay Hayen is a systems engineer from Germany who has dedicated his spare time to the creation of Nuitka, a library that will compile your Python project to C++. In this episode we talked to Kay about what inspired him to create the project, how it operates, and some of the challenges he has faced. It is a very interesting project and it has the potential to let you run your Python code in a whole new way!
Brief Introduction
- Hello and welcome to Podcast.__init__, the podcast about Python and the people who make it great.
- Subscribe on iTunes, Stitcher, TuneIn or RSS
- Follow us on Twitter or Google+
- Give us feedback! Leave a review on iTunes, Tweet to us, send us an email, leave us a message on Google+, or leave a comment on our show notes
- I would like to thank everyone who has donated to the show. Your contributions help us make the show sustainable. For details on how to support the show you can visit our site at pythonpodcast.com
- I would also like to thank Hired, a job marketplace for developers, for sponsoring this episode of Podcast.__init__. Use the link hired.com/podcastinit to double your signing bonus. Linode has also sponsored this episode and you can get a $10 credit using the link linode.com/podcastinit to try out their fast and reliable linux virtual servers.
- We are recording today on October 6th, 2015 and your hosts as usual are Tobias Macey and Chris Patti
- Today we are interviewing Kay Hayen about the Nuitka project
-
Interview with Kay Hayen
- Introductions
- German, family with 2 kids, one cat
- Working in ATM (Air Traffic Management), tracker product
- Systems Engineer
- Nuitka as a hobbyist
- How did you get introduced to Python?
- Once was Perl “Guru”.
- Python was getting a lot of positive press
- Team decision to want to use readable stuff
- CPAN was still more complete, but Python was making inroads
- Can you describe how to pronounce the name of your project?
- Wife Anna, Russian, Annuitka -> Nuitka
- Can you briefly describe what Nuitka is and what your motivation was for creating it?
- I was thinking a fully integrated and compatible compiler should be possible.
- Why is nobody doing it?
- I can do it.
- I am doing it.
- Take Python beyond current use cases.
- Everbody currently using Python needs no compiler, or wouldn’t use it
- Less need for time consuming C++/Python hybrid coding
- Simple code should compile to fast code by default
- Complex code should still work
- On the project web site it says that Nuitka does a lot of clever things after being fed a Python project. Can you provide some details as to what some of that cleverness is?
- Re-formulations of Python into simpler Python
- No “class”
- No “assert”
- No complex assignments
- SSA tracing
- Attaching uses to assignments properly
- Despite try/finally
- Loops
- Avoids checks for known defined/undefined values
- Attaching uses to assignments properly
- Function inlining (coming)
- Constant propagation
- Closure variable removal
- Re-formulations of Python into simpler Python
- What is libpython and how is it used in both Nuitka and CPython?
- Core of the Python interpreter
- With Python VM and C interface
- Nuitka can fall back to it
- Avoiding it as often as we can, key to performance
- Is there any way to provide hints to Nuitka to generate more optimized output?
- Nuitka is yet to make a difference based on type information
- Not yet there, but coming soonish. SSA was pre-requisite
- PEP 484 will be unreliable type information, mostly useless
- I want type hints that are checked at Python run time
- What are some of the biggest challenges in generating statically compiled code from a language as dynamic as Python?
- Python is compiled to .pyc files
- Compatible Frame stack, cached
- Exception handling of Python is terrible
- CPython type system designed to be extensible
- Extension types for functions, bound/unbound methods, generators, etc.
- Many details to get right
- Are there any particular Python constructs that Nuitka is unable to translate and as a corollary to that is the compilation step lossy at all or do you have some way of ensuring that the functionality of the program remains unaltered?
- Big point, no price attached
- Except for not having bytecode, there is nothing missing
- No pdb support
- Edit / run cycle is not accelerated
- That said: PyQt (integrated), PySide (available, unmerged), wxPython (available, maybe merged) needed patches to take compiled function/method objects for function objects too
- Are there any particular types of programs that benefit the most from Nuitka’s compilation?
- Bindings with ctypes of cffi compile into zero overhead C calls (planned)
- Scientific programs are the most obvious goal (float type inference)
- CPU bound or low latency programs
- Is it possible to feed an entire project with multiple modules into Nuitka all at once or is the standard use to perform compilation one source file or submodule at a time?
- You give it the main program and it recurses imports according to “PYTHONPATH”
- nuitka –recurse-all “/usr/bin/hg” supposed to work
- Might have to give directories with program plug-ins
- I’m curious about what led you to choose compilation to C++ for Nuitka rather than making Nuitka an LLVM back end like Numba?
- When I started Nuitka, I was using C++0x and variadic templates
- Wanted to make a proof of concept that compatibility and integration is feasible
- From there, code generation got less high level to goto ridden C
- How does Nuitka compare to projects like Numba or Cython?
- Graceful degradation goal
- Complete compatibility with Python whole stack
- How does Nuitka compare to PyPy? – Kay
- PyPy is the coolest project ever
- Pure Python goals shared
- How can users evaluate the performance of Nuitka – Kay
- They currently cannot
- Developing a tool to compare CPython and Nuitka runs
- Based on vmprof from PyPy people
- Identify parts of program where Nuitka is slower
- Links to source code
- To be done, help needed.
- Nuitka is only starting to get to serious performance
- Compatibility is such a high bar to take
- C++ to C took a year (avoiding C++ exceptions)
- SSA literally took forever
Picks
- Tobias
- Chris
- Kay
Keep In Touch
The intro and outro music is from Requiem for a Fish The Freak Fandango Orchestra / CC BY-SA
Hello and welcome to podcast. In it, the podcast about Python and the people who make it great. You can subscribe to our show on iTunes, Stitcher, or TuneIn Radio, or add our RSS feed to your podcatcher of choice. You can also follow us on Twitter or Google plus with links in the show notes. Please give us feedback. You can leave us a review on iTunes, send us an email, send us a tweet, or leave us a message on Google plus as well as leaving a comment on our show notes. I would like to thank everyone who has donated to the show. Your contributions help us make the show sustainable. For details on how to support the show, you can visit our site at pythonpodcast.com.
I would also like to thank Hired, a job marketplace for developers, for sponsoring this episode of podcast.init. Use the link hired.com/podcast init to double your signing bonus. Linode has also sponsored this episode, and you can get a $10 credit using the link linode. Com/podcastinit to try out their fast and reliable Linux virtual servers. We are recording today on October 6th, 2015. And your host, as usual, are Tobias Macey and Chris Patti. Today, we're interviewing Kei Haan about the Nootka project. Kei, could you please introduce yourself?
[00:01:24] Unknown:
Yes. Hello. Thank you for having me. My name is Kei Haiyan, pronounced German. And, well, I'm, I'm a father of 2 kids. I own a cat, and I'm the author of a Python compiler. That's what I do as a hobby. For work, I, in in the air traffic management, I work on a tracker, and I've developed to be a systems engineer, in that product. So a tracker does take radar information and turns it into tracks, as you probably know all from the movies where, the beam turns around. So, yeah, basically, that is what I what I am.
[00:02:11] Unknown:
Very cool. So how are you introduced to Python?
[00:02:15] Unknown:
I my brother originally started me with Perl. So he told me, learn Perl. He's 13 years older than I am. Learn Perl, and you will be capable of doing things nobody else can do. And I was very deep into Perl and successful with that and was actually using this in my current job, 13 years ago. And, then for the product, and we were reviewing our options. And was getting a lot of positive press, and, we wanted to have a focus on readable because we are in safety staff. Everything that we do gets, reviewed and looked at, and reading it is the most important task to us. So Python seemed like a natural fit, and so I learned it for the job.
So there was some reasons not to want Python then. It wasn't as complete as Perl was, complete in terms of the ecosystem for Perl. Everything existed that now exists for Python. So that was about to change, and, I have never regretted that decision. Actually, I fell much in love with, so I learned it on the job.
[00:03:31] Unknown:
It's interesting how many of our guests have cited moving from Perl as their introduction to Python and wanting to move to something that was more readable and understandable.
[00:03:43] Unknown:
There was this mantra of Perl, there's more than 1 way to do it, and it felt really right for a long time. So you would have this natural language expression. You would it it would feel so natural to code. It feels so fast. But the thing was I couldn't understand my own programs from 6 months ago. So that was, that was not a huge success, when thinking of working as a team on this. Although some people did, but, I think we have we were and are very successful with Python. And, yeah, like I said, I I think when you've done Perl, you get to fully appreciate, the readability decisions that Python made. It's just the opposite end of that.
[00:04:33] Unknown:
So, can you briefly describe what Nootka is and your motivation for creating it, as well as where the name came from?
[00:04:40] Unknown:
Yeah. Of course, I can. My my wife's called Anna. I I I 1 day, I made her a gift. It was a compiler, the Python compiler, and I named it after her. She's Russian. And the Russians have this tendency to not use the real name, but, extensions of that. So they would always attach something at the end. And in her case, it's. And then we shorten it again and say. So that's, that's, that, and the, the form is written. The alphabet, the English alphabet maps very strangely to the Russian 1. So, you can take this as my attempt to confuse the world. And last year, somebody said I could have made it a whole lot easier to name it Anna.
[00:05:31] Unknown:
Yes. But then it wouldn't be nearly so cool. Because I just gotta say, I think that is an awesome name with an awesome story. And speaking as someone who is very enamored of my wife, I think that is just just fantastic that you chose to name it after her. Yeah. It's a very romantic present. I'm sure she appreciated it.
[00:05:47] Unknown:
Yeah. It it's, I mean, if you marry I'm like a I don't know if geek is a word to describe yourself, but I'm totally into, programming and these kind of things. And so if you're crazy enough to marry a guy like that, you have to be tolerant of of these kind of things and appreciate that. And that works pretty well. So Yeah. My wife can definitely relate to that as well. Mine too. So, I named it after her. And, the thing was working with Python in this somewhat serious setup. What I've done there is, we created a middleware that is using, ADA.
The product we have is mostly written in ADA and Python. And it's not just for, unimportant things, but relatively soon, we integrate it into live product and do real stuff. So in the middleware, some of your components are pure Python and, not pure Python, they're linking to ADAL libraries. And that's that's pretty much an achievement, and we are very much into thinking about is this reliable? So ADAR is the most type strict language that I know of. It's, it's easy to make integers that do not mix. For example, if you had x and y coordinates, you can make these different types, and you just cannot easily, use them in in, operations without casting them. So it's very much more strict than, say, c plus plus.
And on the other hand, we have this, full and total type well, type aware language, Python, but it's not strictly checking. And that leads to all sorts of problems and, of course, limitations on the performance side. So this this has kind of driven me into thinking about, couldn't it be any other way? So I was, for a long time, thinking, well, no. It's not possible. And then I turned into, well, it ought to be possible, but then why is nobody doing it? And the more I learned about Python and details, I I thought, well, it could be done, and I was checking with other projects like, Pyrex was a very early candidate, Psycho, a JIT compiler, and Pyrex.
And, Cython, I I produce patches for CITON, as well as for. I looked into these things, and, doing that, I kind of realized I I can do something that can be a fully integrated and compatible compiler. So what PyPI, for example, has a drawback is that you can't just use, QT with it. There's always going to be adaptation because the extension modules don't work, and PyPy is not fully exactly the same garbage collection that the Python is. And your programs I cut I I can't just take a 1, 000, 000 lines of Python code and run it in PyPy and expect it to work the same. And so it's not feasible to migrate to that or CITEN doesn't wanna have to fall. At the time, it didn't wanna be fully compatible with language, Not even complete with language support, it now is.
But, I thought I can do it. And after a while, I decided I am doing it. So what I did was first a proof of concept toy compiler that I announced on the pipe c on the site and mailing list. And, quickly, while doing this, I realized that I can, drive this forward and make a solution that I think the market, if I can say that, wants. More generally speaking, what I think what I'm doing there is also to think out of a box, to take Python where it is currently not used. My interest there is not to enhance any existing use case that I have, but to take it to where it isn't currently. So if people were needing a Python compiler, they wouldn't be using Python. So from the existing user base right now, most most of them, except maybe scientific people, don't need it.
And I want to get the Python community to be rid of having to make these hybrid things that I did for work. So, having to do, some things that need to be fast in 1 language and the other things in another language, that is just a lot of overhead, and it felt like that should not be needed. So simple code should compile to fast code by default, and complex code should still work. That's an overly ambitious goal. It's even insane. I would, say, well, there's some likeliness that it's impossible to succeed. But, with the years, I think I have reached a point that I think I've proven it's possible to succeed.
And, yes. I will say more later on. So brief description is, I was thinking there's a couple of corner solutions there, and I wanted to have a, fully sustainable solution that has all the scope. So the over ambitious, Python compiler, if you wanna say that. Yes. That's, the thing is also I didn't need this to succeed, so I did this as a as an experiment. When I started, I was not so sure how far I can get with this, especially with the compatibility. But, right now, I see that people are very confident dropping very large code bases into and having it just work.
That's, that's the thing that I think, it's very important that you can have this 1, 000, 000 lines of code and expect it to work the same way it did before. Yeah. So much about that.
[00:12:18] Unknown:
So on the project website, it says that does a lot of clever things after being fed a Python project, and I'm wondering if you can provide some details as to what some of that cleverness is.
[00:12:28] Unknown:
Yeah. Yeah. Yeah. I'm I'm pretty sure that, this clever wording was kind of a crowd effort. So it's probably not my own word because that's, for a long time, I was thinking it's not very clever. But, so it does, it does 2 things. 1 important thing is reformulation. So it when it when it works on your Python code, it sees this high level language construct, for example, class statements or assertions or complex statements, complex assignment statements. And for example, a class can be created by calling the type built in and giving it as an argument the name of a class, the base classes, and a dictionary.
That's what this class statement is effectively doing. With a class body that you see, it's assigning local variables in a function, and then returns locals for this dictionary to use. So I would have these sort of reformulations. Same goes for meta classes. In case of meta class, you wouldn't call type, but the meta class. And a lot of the language of Python goes away. And, actually, Python, as its core, is can be represented in a much simple Python. And then I'm compiling that. So for example, if you assign a, b to c, d, there is a series of assignment being done to temporary variables first.
Try finally with deleting on these temporary variables and then assigning from the temporary variables. For example, that's that's reformulation, and you end up with a language that only has simple assignments, for example. So, these reformulations allow it to, sometimes discover that part of the overhead of doing this can be removed, because it's already clear what that dictionary is or the temporary variable can be predicted, these kind of things, and then, NUTICA can throw these, away. Then something I've been working on literally for years is, I maybe wanna talk about this on another question, but it does it does tracing.
And the tracing attaches assignments to use sites. And the code control flow in a language with try finally is pretty nasty because you can exit code control flow, or try accept similarly. You can exit control flow in a lot of cases and, rejoin the double ones. And, getting that right was sort of difficult, especially together with loops. So it traces these things, and then it knows what it is or what is being is it assigned or isn't it assigned? So it's a lot of checks that you can just not do, because you know statically where is a Python runtime, the normal Python runtime, is agnostic of these sort of things.
With its traces, will know that, for example, a parameter variable must be assigned, whereas a local before being assigned isn't, that kind of thing. Also, more complex stuff just works and helps it, making, these determinations or even finding out about exceptions statically. Then it does something that I've demonstrated at your pipeline this year, function inlining. That's in a coming release. I have this only as a prototype code, but I feel it's not general enough. And, it does simple things like constant propagation. So, for example, what we like to do is we like to give, constants names, like, for example, the amount of meters in a nautical mile.
That's you can write down the number and leave people guessing what this means. And that's actually the fastest code. Or you can assign a variable to that constant and then use that variable. And that's, the that's an extra cost. And 1 of my goals is that what I've observed is that people, as software developers, when they know that this is slow, it's somehow in their head. And I want to get into the head of a developer and tell them, no, readable code is not slower. That's, 1 thing that Utica can, definitely achieve. And, another thing, for example, sometimes variables will be shared among functions, but only in some times. For example, there might be a branch to dump something, and then that's deactivated and not run and detect this and, avoid the over hand of shared variables. That that's the kind of things it currently does.
[00:17:37] Unknown:
1 thing I'm curious about is whether NUTKA operates at the textual source code level or if it compiles the code down to the Python AST before doing its optimizations and transpilation?
[00:17:52] Unknown:
Yes. Yes. I'm using the AST module from Python. So originally, I I started out with, bytecode compilation of the source code. And, I went back to source code because I felt like, it will help me ultimately to have a better link to the source code precisely. The bytecode was never going to have a good link to the source code. So the AST module, basically, Nootkat does import AST, ast.pass, open file name read, and, then, walks over this and turns it into 1 of its own, structures. So there you have width nodes, and, Nootka then reformulates some of these into other things.
And it's pretty simple, actually. The passing side is very easy. For a compiler, you have this part where you, put the language into tokens and then represent it as an AST. And I'm just reusing the CPython implementation. So that's 1 of the benefits of, not extending the Python language is that this part is really easy and almost guaranteed to correct be correct.
[00:19:06] Unknown:
And is the output of Nootka a set of source files written in c or c plus plus? Or is it, binary output?
[00:19:16] Unknown:
Yeah. That's a very interesting question. Originally, when I started this prototyping effort, I was largely interested in compatibility. I wanted to know if it's possible to get Exac and EVAL to work, all the, dynamic stuff. And the thing that got me started to think that is even possible, that was, the idea of doing this in c plus plus latest greatest language standard. It was also an idea to somehow learn about, what later became c plus plus 11. And the thing was that this was really simple code generation where I could, for every, node tree element, I just had some sort of c plus plus template and fill on fill in a bit of values and have relatively quickly a demonstration that this works.
Once I had that, I decided that I wanted to be faster. For example, C plus plus exceptions are extremely slow. So when you erase an exception on Python, the c plus plus exception was raised. And the funny thing is that Python exceptions are much faster than c plus plus exceptions. So I was, like, 10 folds lower if an exception raised. So that was not that was not going to be a faster runtime. So I gradually moved away from using c plus plus exceptions. I moved away from using templates, classes. I went to c plus plus o 3, and, it took me 1 year to to get rid of the real uses of c plus plus. So now it's c plus plus, but it's it's go to written.
It's, it's, it it can hurt your eyes to look at It's it was once, it once it was very pretty, so I I I presented slides, which were basically you could almost recognize the original Python code and now you can't so it's now it's got it's structurally, logically, to my heart, it's it's c code. But, I I'm still using a few things only allowed in c plus plus. So that's but it's it's supposed to go away. So it's going to be c, and it's going to be multiple files. Yes.
[00:21:45] Unknown:
So what is lib Python, and how is it used in both duika and CPython?
[00:21:50] Unknown:
Yeah. Lib Python is, is the single reason why this poll project is person is possible for a single person. So I think it was in 2012 that I presented it first to your pipeline and Guido said in his talk, asking why the answering the question why why there is no Python compiler. He said it's not easy, and if it were easy, you would have done it. I disagree I I think it's Python is kind of prepared for that it's sort of easy and lib Python is really what does this. It exposes for Python core. And the core is a virtual machine and a C interface for extensions.
And what I've been doing with Nudger is, basically registering extension types with the core. And for 1 example of this could be, for example, the compiled function is, very similar to a regular Python function and works largely as a drop in replacement. So libpiles allows me to kind of, for example, use the original integer type implementation of CPython and and be good. So be compatible. You just do the same. It allows me to just have had a Python compiler that is just not having bytecode, but making c calls instead, and and it works which ultimately is what the Python VM does when it sees the bytecode. So technically technically this is very important and it's it's an important cornerstone of 1 of my strategy the strategy being that I wanna have graceful degradation so I when I had this compatibility milestones what I wanted to be is, is is compiling code and run it fully compatible. So the CPython test suites, for example, run virtually unmodified.
They they just work in exactly the same way and then, then from there on for example I have a c integer I have this integer implementation of Python a PyInt but, for example once I start to identify cases where I don't have to use it but can get away with the C integer for example then I will just do that and where where things get too complex where where, where interaction with unknown stuff will be needed I can fall back to lib Python and be, compatible. So that's, yeah, sort of, my all after all these years, I've I've finally done it. That's, that's the that's the
[00:25:10] Unknown:
achievement there. Well, I'm quite sure that Guido is is happy that you disagreed and that you chose to take it to the next level of actually implementing it because it certainly benefits us all.
[00:25:21] Unknown:
Yeah. Actually, I got to talk to him about it, and it wasn't it wasn't a warm welcome. Actually actually, he is not too fond of a project.
[00:25:33] Unknown:
That's interesting.
[00:25:34] Unknown:
No. No. You can it would be, it would be no exaggeration to say that he doesn't endorse it.
[00:25:43] Unknown:
Why? Do you do you have any sense of why he he he has an issue with it?
[00:25:48] Unknown:
No. That that's a question he can answer. I can only make a speculation, of course. Yeah. Yeah. But my my speculation was that, to think about the, well, let's suppose I'm I'm getting this done. What it will prove is that an outsider, I wasn't part of the Python community at all. Once I prove it's possible, it changes well, it means, like, had this been done 10 years earlier by a capable person, it might have changed the landscape for Python, a lot. That's, that's something that this may prove. Obviously, it's a large task for me. I might not make it to my ultimate goals, but I think it definitely proves the possibility of, of this. And I don't know. Nobody likes being wrong.
[00:26:48] Unknown:
Right. Right. Well, that's unfortunate. But, but, you know, thankfully, the world of open source is is large, and you can go and do your own thing. And and Guido can do his own thing. And I I I used to say I didn't ask for permission. So this was also kind of like a surprise.
[00:27:07] Unknown:
Actually, I I presented this, and he didn't know the out this. So maybe that's also something that got him upset. Yeah. But, yeah, I I didn't ask for permission, and I received 0 forgiveness. So that's, so far, that's the state of that thing. It's, it's a bit unfortunate. I I actually, I had expected them to ignore this, so because it's not much it's not really relevant until it's ready, and maybe it's never going to be ready. So yeah. So I I wasn't expecting him to be upset with me. Well, it's definitely an interesting exploration into what is possible
[00:27:46] Unknown:
and what it takes to make it become possible. So
[00:27:50] Unknown:
Yeah. Definitely is. And, yeah, I'm I'm going to ask people to join me. The the thing is it's it's limited by me right now, and I would need more people to help me. It's it's definitely with more manpower, we could have is, working already, but, so far, I've not managed to the thing what what I've made out of this is that when I presented this, I was fully aware that at this conference, nobody's going there's nobody there who needs a Python compiler. Nobody needs 1 and, so, why would you do it? That's actually the reason why it never existed is that nobody's really have a had that incentive. You can use c plus plus instead.
You can do these hybrids. It's a well settled solution. And my, my goals are too radical, I think. So, for everybody, else, I think they have got other stuff to do. So that's, except, of course, maybe PIPAI people. I yeah. They don't quite fit fit into my equation. Right?
[00:29:00] Unknown:
So because they're doing the same thing. I'm sure that once it becomes production ready, that a number of people will change their tune and start flocking to it to gain extra performance out of their code at no at no extra cost?
[00:29:13] Unknown:
Yeah. I I mean, I have been having users for many years now and, some pretty big names among that. So it's it's it's being used in production, although I don't, I cannot recommend that. But, I think, even even small gains mean something to some people. So, we're going to talk about performance later more, but, yeah, it's it's not much yet in term of performance. There's not an order of magnitude to be gained, if anything, in all yet. So, the, the user base clearly is there, but, yeah, but, it's it's just, different from, there's not a lot of people, a whole lot of people who could who actually can do these things. That's, already a lot of stuff.
[00:30:04] Unknown:
So is there any way to provide type hints to to generate more optimized output?
[00:30:10] Unknown:
The idea that I have is, like, this is PEP 484, where I I don't like much. Everybody's asking about will Nudka support that, and I my answer is always yes. But I, it's unreliable type information. So the way I understood it so far is that you just add unused source code that could be used as hints to other tools. It's like it's almost like a big form of comment. And if you ever made, worked on a large code base, you frequently found comments that were not aligned with the code. So what's going to happen is that precisely that will be the case, so type ins will be wrong, and I can't rely on that. So currently, it's not possible. The goal is definitely for this to be unnecessary, and, I'm working more toward that end.
And when if there was anything like that, and I'm dreaming of a hints module, is that this would be implemented in pure Python, and it would work in pure Python. And my, code analysis would identify that, the thing that you're hinting at is definitely true because the code checked. For example, if you want to give a hint that something is an integer, so you you could write assert type x isint. Then the compiler will know, from here on, either erase an exception, or it's definitely int. That kind of that's the level of typing, but I'm looking into, pure Python code that just works. And for example, if if you wanted to give me the hint that a module is not written to from the outside, which would me would allow a lot more static analysis, I would ask you to import something that wraps your module so that it becomes inaccessible to everything else, And then the static analysis is supposed to understand that. So I don't know if that's going to happen.
Definitely, it's a tough thing to make. I I can see why, these unused type ins are a good start, but I would prefer something more radical for hints for example if the function has a signature that it's only supposed to be called with integer string list, then check that when it's called or make that at least an option. But that's nothing that exists, so I'm kind of disappointed with that. Yeah. But, right now, truth to be told is NootViewer doesn't use types, type knowledge at all yet. So integer, float, string, it's all the same right now. So that's, that's that. It's something I'm I'm going to attack now that I have this SSA, the single statement assignment under control.
It's something I can only start right now. So working on, optimized code for integers, floats, that's only something that will now begin. And, so I have not invested a lot of effort.
[00:33:28] Unknown:
And following on with that question, what are some of the biggest challenges in generating statically compiled code from a language that's as dynamic as Python?
[00:33:37] Unknown:
Yeah. Actually, let's say, to me, it is, you know, Python is compiled. It's compiled like Java is compiled. It's compiled to a virtual machine code. And the only difference really to something like ADA is not the instruction set that you use for execution, but the lack of checking types. And that's not really making it harder to generate statically compiled code because all I'm doing is I'm replacing bytecode with c code. That's not, that's not, that's not a big deal. So there were lots of difficulties in in in in in making Utica. For example, the frame stack that Python maintains, with locals, globals, and these kind of things. That's, terribly difficult.
There's this exception handling, which has very interesting semantics. I can never remember what, the cause of a context of an exception is. I always have to look up what that is. And this is, very detail written stuff. So but making this transition to to static compilation, it's actually something simple, and I I I I I don't recall right now, but Nudka may not have been the first to to do that. I'm I'm not sure anymore. But, the dynamic nature actually is is not is a nonissue because I I okay. I have this, pie object everywhere. That's not making it harder. That's making it easier.
Right? Because I only have 1 type. It's, Python has just 1 1 type, and that's, 1 c type of a PyObject. That's not it's it's it's easy to, to assume that that must somehow be harder, but it's not.
[00:35:48] Unknown:
That's definitely very interesting because, you know, certainly my assumption going into it is that because of the fact that you can assign different types to variables would make static compilation more difficult. But as you mentioned, having a single c type
[00:36:01] Unknown:
simplifies things a lot. Yeah. And and and and then the the c Python type system is designed to be extensible. So it's pretty easy to put in your own types so once once we work with is what other people call boxes right this py object There's a lot of overhead involved in having these boxes, and I certainly wanna get rid of these soon, for example, do float calculations locally on the stack. But, being allowed to have it is not a complication. It's it's it's simple. I I just made 1 plus. I made 1 minus implementation. Yeah. There's not a lot of performance gain that you can expect from that. But, yeah, with a few tricks and stuff relatively quickly, a 2 to 3 fold increase was achieved. So even without any type inference and stuff, it's easy, to become faster and then gain some extra percentages from avoiding checks here and there.
So, this part of a project was, easy. The really difficult stuff for me was, to represent that relatively dynamic control flow in a structure that allows me to have a single statement, assignment single state assignment and to make that transition because, originally, I had just something that sort of I had a node tree that happened to generate the correct program. But, well, when I was walking my node tree, I I just had no I didn't it was not abstract execution is what you want to do when you do this walking. And in many places, abstract execution was not yet feasible because this structure had to be broken down into something else. So it took me a long time to get just, just that correct.
And, I was basically I was doing a lot of refactoring. And and the every time I completed, I had a compiler that was just about as good as before, but 1 step closer to where I am now. So, yeah. So, with this next release that I'm bound to make maybe this week, I have, I have this fully solved. And that's a year long, many years long efforts to to, to get from something that was more like a templating mechanism to turn the AST into c plus plus to something that is, is an actual compiler. So for a long time, I wasn't thinking of Utgard as an as a real compiler. I I would write many blog posts and say, it's not a real compiler yet because it cannot do this. It doesn't really understand the source code. It's just I I have to I would have to limit it to cert optimizations to certain things, because it it it doesn't understand things properly. And now I can have semi complex functions and inline them to nothing, because I understand these things. And that's a tremendous step ahead. And that was the difficult stuff.
And the, difficult stuff that didn't have to do anything with pipes. It was with, try finally is is just horrible. And that's why some language don't have it, so and especially not at the same time as try accept. So yeah. It's very convenient to the user, but But the implementation is less than pretty. Horrible. For example, if you have try return 1, finally return 2. What do you think is going to happen?
[00:39:48] Unknown:
That is a very good question.
[00:39:51] Unknown:
Yeah. I I don't know right now. Nobody knows right now. I'll have to try that. A return statement in Python code is just a proposal. You can in the you at any time, you can turn this into, into a break of a loop or that's that's just insane. And, and, yeah, the the control flow is much harder of Python, actually. Actually. I I can easily write code, but you cannot you cannot predict, and it's it's short. And that's, I learned some of these things. For example, I or my first versions, I I used, the c break statement in in a c loop for the break statement.
That was until I realized that, nah, nah, nah. That's a break statement, is It has exceptions semantics too. And it can be caught by a final statement, which then can do something else. And there's actual code out there which does this. That was really the biggest challenge, to me. Also, the many, many details of Python, it's insane. So when I was working through this I was working through the test suite of CPython and you have this test a test a b c something like that. I was going by the alphabet and, once I passed test grammar, like, there was test compiler, there were I I I was I was I had learned so much about Python already that I never thought possible. So that's really, it's also very detail rich. You wouldn't you wouldn't expect that. Although it's a very uniform, everything feels like a dictionary, and Python feels very homogeneous.
Python 2, especially, has a lot of tricks up his sleeve. For example, I I doubt that many people know about, Lambda functions that can be generators. I didn't know that. So you can write, lambda, brackets, yield 1, or you can write, Lambda, yield 1, comma, yield 2. And that's also very hard to predict what these things do.
[00:42:04] Unknown:
So that actually brings up another question is, what support Noteca has for Python 2 versus Python 3 and also the different point releases within those?
[00:42:15] Unknown:
Actually, I support I'm I'm trying to be compatible with all that I've seen. I I originally started, I think, against Python 2.5, but I eventually dropped, supporting that. There was 1 good reason. But I'm supporting Python 26 now, 27, 3.2, 3.3, 3.4. And for just released, 3.5, I'm I've made a posting on my site and explained some details on this. I don't yet support coroutines. That's the real big new, thing that, Python 3 dot 5 has. Mhmm. And I would get, to do the catch up game and implement a compiled coroutine code eventually, but I didn't get around to that yet.
So but, other than that, Python 3.5 is supported, and sometimes, even minor changes, between 2.6 7 and 2.68, will behave same way the minor version it is being run with behaves. So it's, it's easier for me to, I'm just for tests, this is a dream project because I have this perfect oracle. So I have a CPython implementation, and I will run a program with that. And then I will make Nootka behave exactly the same way. And oftentimes, it's much easier for me to just add another detail or even a minor version difference just so I don't have to, write something else that white lists some tests as being allowed to fail.
So that's, I have I'm I'm writing in the documentation. I'm seeing absurdly high, compatibility. So it's, it's actually it's insane. It's almost like, I enjoy this kind of puzzle games. So I also got into, the crazy mode of compatibility at 1 point, I suppose. So it's it's just like, I don't know. I've I've I've added compatibility for things that I was initially thinking, No. I'm never going to do that. And and, eventually, I did. It's a so it's also there's some fun to that. It's like a zen.
[00:44:36] Unknown:
So your comment about not being able to support coroutines yet leads me to my next question as to whether there are any particular Python constructs that Nootka is unable to translate. And also as a corollary to that, is the compilation step lossy at all? Or do you have some way of ensuring that the functionality of the program remains unaltered after the after it's passed through Nootka?
[00:44:58] Unknown:
No. I'm just running a large amount of of tests on this. I actually this year, I've, I've burned through my disk. My desktop. It's it's kind of, gave up, and I burned through, quite a bit of hardware now. So I'm running a lot of test. Testing a compiler with continuous integration is kind of CPU intensive. And I'm running programs. So for example, the CPython test suites from 2.6, 2.7, 3.2, 3.3, 3.4, and Zoom's 3.5. I'm running those, and then I'm running Mercurial, and I'm running, test suites of some programs. And then I'm compiling with and the compiled again, and then the source code is supposed to be the same.
And, these kind of things. So I'm doing a crazy amount of testing, and it's pretty much feasible to do a crazy amount of testing. And I have a lot of, exposure by users now. So I I get reported, even very small incompatibilities, and I fixed these for some years. And, basically, we just stopped. I I think I think I've overseen a Python free feature recently. So there was something, some form of complex assignment became possible that I just never encountered anywhere, but somebody read it from a PEP and wrote it. It wasn't in the CPython test suit, so I'm I'm not guilty.
But, it's it's very rare now that something is not, behaving the correct way. So it's, it's pretty it's much easier than I thought to to, achieve a high level of, compatibility. I think once I start to do this type inference thing, I am going to be in more trouble Because right now, with this, everything is just that 1 object type, and compatibility is much easier. But once I start to replace locally, the float, CPython, libpipe implementation with my own 1, There's all sorts of possibility of getting that wrong. That's, and then only some code will run more optimized or less optimized, and the value of this, Oracle, testing, will diminish.
And what I will do, that's a plan, is to ask people, to integrate that into their own continuous, integration setups. So I'm going to add support for talks and pytest and then it should be easy, for people to just run their test suit, and that's hopefully sufficient to give us the assurance that, a sufficient amount of code is, is is running through this, to be to remain sure. I I I have always strived to be, correct. So that's probably my my background is with this ATM. It's, correctness is king, and, this is really where I wanted to be first to instead of being fast.
To me, the interesting question was, can I can I be correct? And so I was aiming for correctness first and, performance second. So that's, I think it's a good spot to come from something that is working, making changes on that as everybody knows who's doing continuous integration is, if you have a good test coverage, that's going to help you, avoid false decisions. So what's not working? That was the question. Right? So I got a bit distracted. So the the thing I am not having is, I'm not having bytecode. So the code object of compiled functions is empty.
And that also means you cannot attach the Python debugger, so PDB. It's mostly useless with, with compiled code. And, to me, that's a big point of of of Utica was that there should be no price attached. So I've strived to make sure that nobody's nobody's supposed to change the programs so in order to support. So that's the other way around. And that's, that's working, that's working. And the code objects and the flags on that and all the details that are actually used are there. So, it's a serious bug if, if the software doesn't run out of a box, and Nuka is being exposed to, much code. And, I I'm usually the default report. It just works.
[00:50:04] Unknown:
That's definitely a good way to help encourage adoption, being able to say, you don't have to change anything about your code. Just pick up pick up and start using it. So
[00:50:14] Unknown:
Beat that. I mean, I'm not performance is my weak side, which is which is sort of ridiculous, isn't it? But, but, I I was not convinced that people can use a compiler for serious stuff if if they cannot be sure it's
[00:50:32] Unknown:
correct. Yeah. You definitely need to start with making sure that things work, and then you can work on making them work better.
[00:50:38] Unknown:
Yeah. And it's it's it's very the industry I'm working with is is very conservative. And, I wasn't, I wasn't going to, I wasn't going to have benchmarks at running at lightning speed when I perfectly know, but later on, I will have to make changes. They give up on that. So that's, that's just, that's, probably I would have more contributors. Yeah.
[00:51:08] Unknown:
It's it's it's, it's it's part of what I am. And so are there any particular types of programs that benefit most from compilation?
[00:51:17] Unknown:
Yeah. Surely, if you're CPU bound, that's clearly a prerequisite, or you should be latency bound. So if if sometimes you have a program which wants to be real time, soft real time maybe, and still be Python. And then, for Python runtime, even if you don't run-in a loop, you just wanna finish as soon as possible, then also compilation can, of course, be very useful. Scientific programs are my, most obvious goal. Once I am capable of doing this type inference and have dedicated code for float, I think, NumPy NumPy allows people to write most of their code in something that will be executed on in in c extension code. But the part of the program that you write, it's it's it's written in pure Python so here's 1 callback that's being executed for a matrix that's the part where you get slow and, the idea is to integrate there and to make this, c speed.
So once that what's that would be in place, and I'm hoping for somebody, university, some professors work with me and students there maybe to to do some integration there. That would be a interesting goal. And then what I'm also where I'm coming from is what we did was bindings with c types and I think pypy created c f f I which is also a good idea and what Utka should become able there that's that's that's my next goal actually my first my first goal what I want to do with type inference is to make a demonstration of 0 overhead binding so I want to make chords into say lipc or qt or whatever it is and demonstrate, look, you can do this, with c types bindings. You could do stuff. And, yeah, it's just as if you had written this. That's that's, if I manage that, I want to get offers of bindings to use pure Python for their, work on creating bindings and, move this into this hyphen world allowing for better optimization. That's 1 of these immediate goals.
That's the programs I'm aiming at. Largely, scientific community is very interested in Utica. Financial industry, pretty similar. I don't have much contact there, but I get that they are lot using a lot of Python, data analysis too, and, that could be run faster out of a box. Right? So that's definitely interesting. I think the normal program that you and I write, even itself, won't benefit as much. Although obviously, is going to be more CPU bound than other programs.
[00:54:17] Unknown:
And your comment about the possibility of using compiled code for supporting soft real time systems reminds me of the fact that you mentioned you had spoken with Damien George of the MicroPython project. And I know that he is currently working with the European Space Agency to try and see if MicroPython is something that would be feasible for use on equipment used in interstellar missions. And so it sounds like Nootka and MicroPython would be a perfect combination for that type of project.
[00:54:51] Unknown:
I think MicroPython might be I'm a huge fan of MicroPython. I talked to Paul Bode in emails years ago. We eventually stopped because I I reckoned that we're just we're having very productive discussions, but, I was, like, discussing in a few in a distant future, like, to where I'm now. So where I'm now was sort of a prerequisite of what we were discussing. Mhmm. And, there's a lot of common ideas and ground there. The thing is that, micropython is is, I think, geared at being a tailored solution, and it's not going to benefit from the whole Python ecosystem. And, it will fit into a small hardware and stuff.
And, what I'm looking at is is probably more like, well, you could, maybe maybe it's more for the smartphone sized, embedded hardware if you want. I don't think, MicroPython, is MicroPython is going to be more suited to that. If you wanna have this, soft real time, I I think you're going with micropython. Right? But that was just generally a comment where where it could have provide benefits. Obviously, if if you really were into real time, probably, shouldn't use Python. Right? You should use MicroPython or something else. Mhmm.
[00:56:25] Unknown:
And so I'm sure the 1 question that our listeners are most anxious to hear is how Nootka relates to the GIL and if there's any possibility or future plan to produce compiled code that makes threading and usage of multiple processors easier without having to make any large changes to their Python code?
[00:56:47] Unknown:
Yeah. You know, I'm already having this crazy idea of creating this Python compiler. You know? I have this other crazy idea that static analysis should together with, something I was going to talk about, profile guided optimization. Recently, I was thinking like now if you if you give me these, tests of yours and let me run it so that's how profile guided optimization works. You collected runtime, type information, what maybe the way and the order you access things, and, it could be possible to identify parts of a program that do not overlap in your test setup. And doing that, we could guard the excess of, across the boundary of these, with, blocks, finer grained blocks that, cover these, sets. And with the help of user annotation and profile guided optimization, we could identify the few spots where things that are affecting happen, and I I contend that it's possible, to to get even with CPython a parallel execution, you just have to avoid the memory allocator.
The memory allocator will, must not come into play. So this internally, it it uses a cache of things. And, once you run into using and interacting with it, that's going to be painful. But, there was also a pyparallelguy who had a working prototype of, speculative execution. So it's basically along the line of, software transactional memory. But for PyPI people, content, you can observe what the program does. And, then we could generate code that makes the actual conflicts manageable. It feels like, at least for benchmarks, it's going to work pretty well. I don't know, how it works for real life programs to do this. But if you're really interested, I I I see this on a on a very distant horizon, of.
So I don't know if I ever going to make the that I wanna have, but I I know that once if it exists, this should be possible. But with a GIL, it's like, it's it's like these these things like, it's like a Python compiler. Everybody thinks removing the GIL is possible, but nobody's doing it. That's, unfortunately. So so I've been to presentations on how the GIL could be removed for I've seen these for years now nobody's doing it so maybe eventually if I live long enough I will do it But just just in this, just tailor to your program's static analysis, and I think profile guided optimization, I I can compile a version of the program that will tell me about all sorts of collisions. So you run it, and it would tell me about the collisions.
And you run it. And each time it's running, it it can feed me back with possible collisions, and, ultimately, that may result in a data set that is workable for this. So but it's insane. And, I mean, really, if I were to listen to this, okay. So this person tells me it's going to create a perfect compiler and solve a good problem, after dinner. I'm not trusting it. Like like what originally when I was thinking, it should be possible, I already actually, I think I have a good track record, in the offline world, which is not visible outside of mute. I have a good record record at when I think something is possible, most often, I can do it.
[01:01:04] Unknown:
Yeah. I remember reading an article a little while ago about somebody who several years ago actually succeeded in removing the GIL from Python. But because of all the additional checks that they had to put in place, the resulting code actually ran about 2 and a half times slower than when the GIL was present. Yeah. But that was on a single core. And I think, originally, I think Guido made the decision,
[01:01:26] Unknown:
to not sacrifice single corporate. And that's and also, very understandable. The thing I I I I think I can perfectly sympathize with, Guido there is that he created Python, and Python is also something he did. Right? So it was something that he thought could exist, and he just did it. And beautiful, it's simple. And not having the means you have to be a lot more complex in the code. And I also think rightfully so, the Python, core community, or Guido didn't want to have that complexity without I don't think I don't think Guido is all that convinced that Kraken has to be fast For him, it was like, there's always see if you wanna be fast. So and he's right about that.
But it's I I I wanna move it out of that box, But, technically, the JIL is only a problem if you wanna be fast. Certainly. And nobody needs that.
[01:02:29] Unknown:
Is it possible to feed an entire project with multiple modules into a new all at once? Or is the standard use to perform compilation in 1 source file or sub module at a
[01:02:39] Unknown:
time? That's that's strategic. So, I 1 thing I've learned over the years is also that you it must be usable or it's not used. And it's it's it's it's ridiculously simple to use. So you would say Nuka, main program dot pi, for example, use up in hg Mercurial. And, then we'll ask you, well, yeah, I just compiled h g, but I'm not recursing to the Mercurial sub module. Please add the following options to do that. And then you say, newcomers all userPin hg. And then it just, abstracts, executes this main program, find the import. Wow, it's, it well, it's, it's an incredible amount of work to have to to get that compatible.
Originally, I was using, Python code for that, but turns out that that's not compatible enough. So I got to, reimplement this whole thing, and it has a lot of details. For example, case sensitivity and, order and stuff. It's, it's it's really, really, relative absolute imports. It's very confusing. Actually, every time a a bug is found, I'm shocked, and, I know it would take me literally 2 days to understand what this is all about. But, it just works. So I have multiple modes of operation you you can compile a whole program you can compile a single module into an extension module you can compile module and other modules or a package into 1 thing and basically all the modes of operation imaginable are possible.
1 popular mode is also something called standalone so when I compile I see this mostly as a means for a calibration but there's a world of people who think that the compiler is also to take a binary and put it on another system and have it work, and stand alone does that. So, essentially, it creates a mini distribution of Python, shared libraries in system, DLLs. And, you can copy this to another system, and it will just work. That's also a very popular use of to, for distribution. Although, I I'm pretty sure there are other options, CX freeze or that sort of thing, which are also good. But, it seems like people like to use for that. So what pie 2x once did. I think pie to x may not support Python 3 or but, yeah, it's
[01:05:32] Unknown:
it's it's it's ridiculously easy to use. That's great. So I'm curious about what led you to choose compilation to c plus plus for NUCCA rather than making Vika an LLVM back end like Numba.
[01:05:43] Unknown:
Yeah. I was thinking, of that too once. The thing originally I explained is, I wasn't going to start the project if I had to do a a later thing. I I just wasn't going to do it. Doing that, c plus plus macro so I would literally write a code chunk in c, plus plus with, with classes, with, distractors doing all the things automatically. So, for example, releasing objects was just something I didn't care about. I would have a local variable class and a temporary variable object class, and they would just do that. And I would fit just expressions into with template, and things just worked. And that was very, very easy, to get started. And an LLVM backup, on the other hand, wasn't going to, be that easy.
So you wouldn't I wouldn't have had the structures of C plus plus doing things for me. So it it was also about yeah. It was it was going to be a proof of concept. Later, I when I revisited the decision what what I wanna be, I I thought that, c is already, relatively low level. So I wanted to also have, for example, c plus plus exceptions and, that kind of thing. It it seemed, it seemed, a very good way to start, what was already an ambitious project to make this compatible Python compiler. And, later, c just seems like close enough to, the end language, but not being dependent on LLVM.
I don't know if you ever heard of the, Anlaten Swallow project. I'm not sure I'm pronouncing that right. That was Google's Python compiler. I didn't get to talk to a lot of people about it yet. It it just died, and it died from LLVM bugs, and it died from yeah. It it was just being dependent on 1 compiler is it's it's a risk. And, yeah, with c code, I can go wherever, Python is. So now I I am not dependent, on any particular back end. There's also some prices to pay, to to support the Microsoft and to see an LVMC code. But in theory, it's pretty pretty low level that you write. It's easier to read, and, I know how to do that. So
[01:08:31] Unknown:
That makes perfect sense.
[01:08:33] Unknown:
I'm not sure. I, actually, I'm not sure if that's the best decision. I I thought about it. I I probably just, I just, because I I saw Cython, I I thought, it's nice to to to to to have a source code and be able to edit it and save and, run it and see if it's any different. I don't know if if the l l v n byte code approach can also do that. I just don't know.
[01:09:01] Unknown:
Right. And it makes sense, actually, you know, hearing you speak about it. I can see that having that extra abstraction that c plus plus gives you would make building the project that much easier for 1 thing. I mean, if you are already a native c plus plus speaker, then there's no reason you shouldn't make use of those abstractions. So that that makes sense even in and of itself. At least to get started. Right? So and, from there, I'm gradually migrated to something that is now much closer to
[01:09:29] Unknown:
to v l VM bytecode maybe. But, for starting out and having something that is actually working and having that, it didn't take me that long. I I'm doing this in my spare time, and maybe 1 year later, I was having it or maybe less. So it's definitely, it was, attractive to to have this gradual migration. So even if I now have go to written SQL, you could be better about, sequence points. You could be a bit more optimal with this. Yeah. Maybe maybe 1 day somebody, can change that. It's, it's definitely the cogeneration is getting stupid enough for this, to be done by whoever wants to at some point.
So code generation, I envision that some at some point, somebody might also generate Python code from Python. That that would be a cool project if somebody wants to take on that. So taking a complex Python and making a more optimized Python version out of that, then you do how not have any drawbacks of compilation. The kind that's the kind of thing that I would like to see ultimately. It's, the code generation is getting incredibly thin layer now, with becoming easier to replace us.
[01:10:49] Unknown:
Yeah. I wonder if in the future, it would be possible to even create a back end to it that does code generation that outputs rust code, for instance.
[01:10:59] Unknown:
Mhmm. Yeah. I mean, I'm I'm going to mention PyPI later on, but, ultimately, it would be cool to have this. But, maybe when the project advances, that's going to be possible. But you have to be aware for my graceful degradation plan. You always need, libhyphen. So for example, JavaScript in a browser, that's not going to happen. PyPI was going to do that or did that, actually, or does that. But, for my graceful degradation, there's always going to be some percentage of a program that is going to run-in in lib Python just because it's too unimportant or something, or too difficult or too complex or too, confusing.
And I I will never have a complete replacement for libpythons. That's not going to happen. It's always going to be in a calibrator around libpythons. And then going to a whole different, runtime, maybe it's possible to have libpipe and Rust at the same time. I don't know. And so how does Nootka compare to projects like Numba, Scython, or Pypi? Well, Numba and Python. Right? I have this graceful degradation goal that I mentioned a couple of times now. So, basically, Python doesn't doesn't intend or wanna be compatible or capable of running your whole Python stack.
It wants to do the job that it's aiming at writing extension modules in the language beyond Python. It does that pretty well. I think it's a tool I would recommend if you wanna be fast and use Python now in code to write. So I would recommend Python for that clearly. Number is something that I've not ever used, which is probably a shame. But you have to be aware that I'm doing this as a spare time project. So I'm not I learned of it, at some point, and then I was told that this is legit, and maybe it now does static compilation too. But the thing I that immediately put me off is that it's not going to be fully compatible. So that's not this graceful degradation code, but it's just some sort of pipe and code that works in in somehow different ways. So that's not it's not going to give us the whole Python stack.
And I think that's, I'm not against multiple projects. I I know that this some people tend to think that other projects shouldn't exist. I'm not that kind of person. I'm I'm for plurality, and, I think, we better bet on on multiple cards. So I I like every of these projects. But I I'm I would like to have something with a 0 cost, full compatibility goal and rather integrate with these 2, than, which it does, by the way. So in a typical, new compiled program, there's going to be a lot of sites compiled SQL. Yeah. That's that's that's definitely 1 difference is, that you cannot throw a number on on on your million lines of program, unless I'm mistaken. I don't know. So I I never looked at what it's actually producing when it comes. So that brings us to to Pypi maybe.
Pypi is something that deeply impressed me. I think it's the coolest project ever. I told this to the PIE PIE people every time I meet them it's, definitely cool and I was contributing to it even at some point in very small ways, ridiculously small ways. I was just making minor fix ups for, my use cases, but, they share the pure Python goal so what pypy really want to do is, is also carry a full load of being capable of everything except that they don't really. That's also the idea of why and, the fundamental difference of of JIT compilation versus static compilation. I I I I chose, to think that you will always be limited in what you can analyze at runtime.
And there's only so much to gain there. And that the ideal approach will always be a hybrid. My secret plan, profile guided optimization, should actually make me competitive with the JIT. The JIT has this warm up phase where it's it needs to find out what's happening before it's actually speeding up the program. And profile guided optimization is like doing that and then saving result and using that for static compilation. So I think on benchmarks, at some point, Utica will hopefully be able to outshine PyPy. Definitely not the case currently. I think if you wanna have fast Python, pure Python, I would recommend everybody to go with pypi currently I mean like literally that's, I think the best options if if you can fit within their constraints. I think the amount of hardware platforms support is limited, and, Python versions is limited. They don't do Python 3 latest stuff.
I think 3 dot 2 or 3. I have they somehow stopped at some point. And, yeah, it's also a slow moving project. But, they share my goals, so that's but it's radically different. And the other 2, they they are kind of more, like, niche solutions, but maybe that's also why they become more successful ultimately. I think that number and site and totally have a potential to, always be, the go to solutions for fast things, and I might just come too late. So that's that's how I would compare. The the thing is Jupyter is, definitely something that is maybe getting ready, and Numba and Cython and PyPI, these are things people actually use today, and, rightfully so. So I have these users crazy people, but I have no way of demonstrating, for example, how fast I am. And And so how can users evaluate the performance of to
[01:17:25] Unknown:
determine whether they should use the output of Nootka or if they should just continue using their Python source code?
[01:17:33] Unknown:
And so except for the good news that function inlining is now about to work and stuff on your Python, basically, I presented this as my hugest problem is that you just cannot. So so people use this and find out it's good for them, and then they use it. But it's very hard to predict so because I have reports from other people who use it and tell me it's slower. There's also 1 guy, I think, pythonperformance.org, dotcom, dotnet. I don't know the exact It's worth 1 guy benchmarking, different compilers against each others. And NUTKA is not comparing favorably to all the time.
Sometimes it's slower, sometimes it's faster, and that's, that's something that clearly needs to change. I have looked at some benchmarks and made some things fast, but there's definitely, things lacking. And so my goal is to develop a tool that compares CPython and Nudka runs. So you would run your program with CPython, and you would run your program with, and it's based on something that PyPI people did. So I was presenting this as my problem. And, is to compare their implementation to the reference implementation. So they developed the mprof, which can analyze CPython performance against PyPI performance, or, after my work, I can also compare it now to even Docker performance. It's not yet, pretty, but, I'm working now on a tool that people can use to run it and then turn this into a back report.
Look here dysfunction, neutral slower there. And then I can change that and must be more consistent about speed up. So right now, I have maybe 2 to 3 for some code and minus something for our code. That's not, that's not, that's not a promise. Right? So I'm not promising that. Or at least I try to. Of course, there's always a temptation to say it's good. And, that's to be done. I I was asking for help, but, well, I I wanna have help with that and basically all doing benchmarking and performance and all all these sorts of things. That's a tremendous amount of work, and, surely, I need help there.
But I'm going to work on this part real soon now. So I'm going to make some type inference stuff, and I'm going to make this tool. This is this is what where where I wanna aim it. And then I think I will have something that that is entirely new, like like something that, can help me to work people who encounter performance issues with Nude curve or for and for people to evaluate comparatively what is it going to give me exactly, and where is it going to give me that and why not. That's great. So I'm only starting to get serious performance now.
I've I have a link in my article on the on the side where I have a 20 fold, 10 fold, 20 fold. I think a huge increase in for in in in some constructs already, a lambda function, which whose inline gets calls gets inlined. The thing that will happen more regularly when when I, get the function inlining operation. That that that's, the amount of factor where I wanna be. But, the compatibility, that was such a high bar to take, but it's literally, took time. Then some of the easy early decisions that I made, c plus plus 11, c+exceptions, and so on, getting away from that gradually, that also took a year.
And then, the single statement assignment, so basically, from from the first version where I presented to what I have now, 3 years later to, to EuroPython 2, 012 to 15, I was working on this, and it wasn't complete, 3 years later, but only now. So more than 3 years of gradual work, to get that working. That was a long time. And, auto Yeah. It's kind of terrible if you make a compiler and people are asking you, but how good is it? What does it do and stuff? And, you get to pick. I I I got to pick, do I document how bad it is, or do I get do I improve it? And I I I tend to just improve it and ignore requests, for this performance stuff, comparative performance stuff.
And, but now I'm going to use this because now I could finally turn to, performance, actual performance. I used to be in a I used to be making performance optimizations like, most of my jobs so far, and not as much in the last 1. That's maybe also why I started Utica. And, yeah, it's I'm pretty sure that I can make some pretty quick progress in the next year. Yeah. But, to answer your questions, they currently cannot use, evaluated performance of except for compiling and running our own programs and benchmarking that. That's that's about it. And if it doesn't if it's not if it's not a good value, there's no way of telling why. That's, that's the problem I need.
[01:23:20] Unknown:
Well, before we move to the picks, are there any other questions that we didn't ask that you think we should have or any other topics that you want to bring up? I I wanna highlight the fact that,
[01:23:30] Unknown:
I I I'm doing this on my own as a spare time project, and I'm not against working with other people. I I feel like I, I'm not hard to work with, so I I definitely wanna have people join me. Also, I would like ask people to I have a donations. I'm not asking a lot for donations, but, I'm, it's well, I'm I'm giving all of my spare time to the project, and I'm also having hardware costs, for example, having to replace my desktop, or my keyboard on the laptop recently broke for the second time, just because of wearing off. And that's, well, if people were, giving me a donation that would also be validation to my wife that this is somehow, worth my time. And, yeah, so that's, join me, help me, and, I think to me this is all what I was hoping for more I was hoping for people to join me with this. It's a it's a it's not PyPI, it's not the coolest project in the world ever, and it's not that far away from it if you wanna join it.
We can make it we can make it also cool ways. I am having a plugin framework added recently, and I put some hopes on that. So there's now a plugin for example which does handle multi processing module on windows and apply some hacks and it would be possible to do plugins which transform the source code as it gets compiled, plugins that will, be able to monkey patch compiled code, inspect things, change things, hint types. This will be, I think, a fun area to, work and expand on. It's a it's a sidekick that I'm working on, and I'm hoping that this will expand things. And I'm I'm hoping that people will, join and enjoy that. But, really, I'm almost feeling like a crazy person doing this on my own. I'm the only 1 sort of, help me stop that and not by stopping mute.
[01:25:44] Unknown:
Alright. Well, thank you for all of that very interesting information, and I'm sure our listeners will appreciate that as well. And to any listeners who have the skills or ambition to take part in the project, I definitely encourage you to do so because it seems like there's a lot of promise there.
[01:26:01] Unknown:
Yes. Promise. And, I'm do I've done the groundwork. It the the fun is about to start.
[01:26:08] Unknown:
So for my first pick, I'm going to choose a board game that I, got recently and started playing with my son called Forbidden Desert, and that is actually a sequel to the game Forbidden Island. And they're both cooperative games where you are trying to move around a grid of tiles. And as the game progresses in Forbidden Desert, there's a sandstorm raging that will push the tiles in different directions and bury them with sand. And you have to try and excavate the flying machine flying machine so that you can escape the city before it gets completely consumed by the sandstorm. And so it's just a really interesting game mechanics. A lot of fun.
It says recommended ages of 10 up but I've been playing it with my 5 year old and he loves it. So definitely recommend checking that out as well as Forbidden Island. And for my next pick, I'm going to choose the auto project from HashiCorp that they just announced as a replacement for Vagrant, and it's intended to simplify creating development environments and then promoting those up through to production. So I started playing around with that a little bit. I've been meaning to spend more time on it, but it definitely seems like it has a lot of very interesting ideas. And it's pretty intriguing how they hook that into a lot of their other projects that they've created such as console and Terraform for being able to create build and release onto production infrastructure.
[01:27:44] Unknown:
And with that, I will pass it on to you, Chris. Thanks. My first pick is a beer. I have been on a grim brewing kick because they are awesome, and they produce really unusual beers. This week's is called grim supersymmetry. It is a dry hopped Go's made with lemon zest. And as I said, they just create these beers that you look at them, you know, when they get poured and you're just like, that's gonna be interesting. And they have a really interesting nose and really interesting flavor. This 1 is has just, you know, a little bit of sour tartness and you can taste the lemon zest. It's it's a really good beer. My next pick is a really interesting website.
It is I love to work with this on in the background. I know it's gonna sound like an odd mix. But it plays sort of ambient electronica with in the background, they have the, Boston PD dispatcher and police radio overlaid over the electronica. And so what you end up with is this really, kind of, interesting surreal mix of ambient music every once in a while punctuated by a radio exchange. And it's I think it's great to code by because you occasionally get that minor, minor distraction that that, like, you know, catches the 3 brain cells that need distracting off guard long enough for you to actually able to, you know, take a breath, and and and finish writing your code or whatever. It's, it's really neat, so I highly recommend it. And my last pick is a, a currency for value exchange. I refer to it, I, you know, don't refer to as a cryptocurrency, only in that it's not really meant to be used like Bitcoin or anything like that. It's called Ripple.
And what makes it really into a lot of really interesting technical aspects to the way it's built, It does not use proof of work. It uses, basically, you know, various nodes in the network need to agree consensus. That's what it is. Sorry. Brain fart there. And the reason I'm mentioning it aside from the fact that is technically interesting is that 5 of the world's major banks just agreed to utilize it as a standard. So that if you, make financial transactions at 1 bank, it will go over their private ripple network to the other bank. And so interesting stuff. That's it for me. Kay, what do you have for us?
[01:30:07] Unknown:
Yeah. So so 1 thing I clearly wanna point out is that I've talked to a lot of, Python Implementers. And MicroPython, I think that's really the most impressive thing to me. They have a lot of science. I talked to his, Paul, and I listened to your podcast from Damien. Very interesting stuff, and I would recommend everybody to look into this. It's much more than I initially thought it is, and there's a lot of clever ideas in here. Lots of which I got introduced to and will be using, and I think that will make also help make unique.
And the other thing 1 thing that changed my life quite a bit was applying skeptical thinking. I, at some point, ran into the atheist experience. And from what they call a deist, I turned into an atheist, but that was only a side effect of, what they really do is to teach you, to learn skeptical thinking. And that's something that made a deep impact into, lots of ways. We always tend to be hopeful and thinking and assuming things to be true without good reason. And that's a general principle, and I've learned that even as a technician, you, you need to be very skeptical before you believe something to be true. And that's I would recommend, everybody to check that out.
Need not affect, what you believe, but I think it's very important to learn to have good reasons to believe something. So that's what I think is interest, and it's something that I encountered. Yeah. And I would like to thank you. I don't know. I probably going to get the for the for having me on. I've seen the list of speakers so far or interviewees interview person so far. It's a great honor to be on and, really enjoyed it. And, I, definitely found, what I've heard of you so far very interesting. So thank you for having me. Well, thank you for taking the time.
[01:32:30] Unknown:
Certainly. And, hopefully, we can get you some better exposure and get some people interested in helping you out with the project. This is a very easy way to, get across a heavy,
[01:32:41] Unknown:
signal message to your listeners. So that's, I appreciate the chance to, get that exposure.
[01:32:48] Unknown:
And so for anybody who wants to follow you and the Nootka project and keep in touch with you, what are the best channels for them to do that? Follow nuitka.net,
[01:32:57] Unknown:
of course. I have a blog you can subscribe feed. And then, of course, I'm on on Google Plus, but, I'm not sure plus k high end. I'm not sure that's going to live for very much longer. Right? So I I don't do much social stuff otherwise. So even then, I'd only very occasionally post on, you know, on Google plus. I'm reachable via email. If you have a question, it's on my website, k.an@gmail.com. I, I have a very liberal policy. Everybody gets to write me, and I, I answer even stupid questions. So it's, so far, I can do that. So, if you have anything or wanna get in touch or if you wanna make my days, there's been people who just send me, emails letting me know that I've, that it just works, and they would like to thank me.
That's a great way of, making my day.
[01:34:00] Unknown:
We greatly appreciate you taking the time to join us and speak with us today. Thanks. Bye bye. Thanks. Bye bye.
Introduction and Sponsorship
Interview with Kei Haan
Kei's Background and Introduction to Python
Transition from Perl to Python
Challenges with Perl and Benefits of Python
Introduction to the Nootka Project
Naming and Motivation Behind Nootka
Technical Details and Innovations in Nootka
Clever Features and Optimizations
Function Inlining and Constant Propagation
Readable Code and Performance
AST Module and Compilation Process
Output of Nootka: C/C++ Source Files
LibPython and Its Importance
Community and Guido's Reception
Challenges and Future of Nootka
Type Hints and Static Compilation
Challenges in Statically Compiled Code
Support for Python 2 and 3
Testing and Ensuring Compatibility
Limitations and Debugging
Use Cases and Benefits of Compilation
Nootka and the GIL
Compiling Entire Projects
Choosing C++ Over LLVM
Comparison with Other Projects
Evaluating Performance
Future Plans and Community Involvement
Picks and Recommendations
Contact and Closing Remarks