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 RSSFollow 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 notesI 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.comI 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 PattiToday we are interviewing Kay Hayen about the Nuitka projectOn Hired software engineers & designers can get 5+ interview requests in a week and each offer has salary and equity upfront. With full time and contract opportunities available, users can view the offers and accept or reject them before talking to any company. Work with over 2,500 companies from startups to large public companies hailing from 12 major tech hubs in North America and Europe. Hired is totally free for users and If you get a job you’ll get a $2,000 “thank you” bonus. If you use our special link to signup, then that bonus will double to $4,000 when you accept a job. If you’re not looking for a job but know someone who is, you can refer them to Hired and get a $1,337 bonus when they accept a job.
Use the promo code
podcastinit10 to get a $10 credit when you sign up!
Interview with Kay Hayen
IntroductionsGerman, family with 2 kids, one catWorking in ATM (Air Traffic Management), tracker productSystems EngineerNuitka as a hobbyistHow did you get introduced to Python? Once was Perl “Guru”.Python was getting a lot of positive pressTeam decision to want to use readable stuffCPAN was still more complete, but Python was making inroadsCan you describe how to pronounce the name of your project? Wife Anna, Russian, Annuitka -> NuitkaCan 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 itLess need for time consuming C++/Python hybrid codingSimple code should compile to fast code by defaultComplex 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 PythonNo “class”No “assert”No complex assignmentsAttaching uses to assignments properlyDespite try/finallyLoopsAvoids checks for known defined/undefined values
Function inlining (coming)
Constant propagation
Closure variable removal
What is libpython and how is it used in both Nuitka and CPython? Core of the Python interpreterWith Python VM and C interfaceNuitka can fall back to itAvoiding it as often as we can, key to performanceIs there any way to provide hints to Nuitka to generate more optimized output? Nuitka is yet to make a difference based on type informationNot yet there, but coming soonish. SSA was pre-requisitePEP 484 will be unreliable type information, mostly uselessI want type hints that are checked at Python run timeWhat are some of the biggest challenges in generating statically compiled code from a language as dynamic as Python? Python is compiled to .pyc filesCompatible Frame stack, cachedException handling of Python is terribleCPython type system designed to be extensibleExtension 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 attachedExcept for not having bytecode, there is nothing missingNo pdb supportEdit / run cycle is not acceleratedThat said: PyQt (integrated), PySide (available, unmerged), wxPython (available, maybe merged) needed patches to take compiled function/method objects for function objects tooAre 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 programsIs 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 workMight have to give directories with program plug-insI’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 templatesWanted to make a proof of concept that compatibility and integration is feasibleFrom there, code generation got less high level to goto ridden CHow does Nuitka compare to projects like Numba or Cython? Graceful degradation goalComplete compatibility with Python whole stackHow does Nuitka compare to PyPy? – Kay PyPy is the coolest project everPure Python goals sharedHow can users evaluate the performance of Nuitka – Kay They currently cannotDeveloping a tool to compare CPython and Nuitka runsBased on vmprof from PyPy peopleIdentify parts of program where Nuitka is slowerLinks to source codeTo be done, help needed.
Nuitka is only starting to get to serious performance Compatibility is such a high bar to takeC++ to C took a year (avoiding C++ exceptions)SSA literally took forever
Picks
TobiasForbidden IslandForbidden DesertOtto ProjectGrimm Super SymmetryAre You Listening To?: BostonRippleLearn being skeptic, Atheist ExperienceMicroPythonKeep In Touch
Nuitka HomepageGoogle+EmailThe intro and outro music is from Requiem for a Fish The Freak Fandango Orchestra / CC BY-SA