This week we welcome Ivan Levkivskyi (@ILevkivskyi) as our PyDev of the Week! Ivan is the author or coauthor of several Python Enhancement Proposals, specifically 483, 484 and 526. In other words, Ivan is one of the lead developers behind adding type hints to Python via the typing module. Ivan is a scientist and as such, he has written a lot of interesting research papers, which I will readily admit that they are over my head. You might also find his Github page interesting as he is involved in a lot of projects. Let’s take some time to get to know our fellow Pythonista better!
Can you tell us a little about yourself (hobbies, education, etc):
I work as a researcher in theoretical physics. I was more interested in mathematical physics in high school, but now I mostly interested in mesoscopic physics — area that investigates the boundaries between our macroscopic world and the quantum microscopic world. I have been learning physics for about 20 years and never had any CS education. Although, I should note that my rough familiarity with category theory helps me in the programming world.
Most of the time, programming was rather my hobby, only the last 5 years I have been programming for work. My first acquaintance with programming was learning x86 assembly at an age of 10. Then I played with other languages from time to time. And now I use Python a lot in my work, mostly for prototyping and number-crunching.
I am from Ukraine originally, but now live in Switzerland. Apart from physics and programming, I like mountain sports: hiking, rock climbing, ski touring, etc. Also I like listening to music a lot and I used to play accordion and bass.
Why did you start using Python?
I first tried Python when I was playing with automated trading strategies (purely for fun) in 2009. I was struggling with some data processing in Mathematica, and a friend showed me Python. I was impressed by list comprehensions — it was love at first sight 🙂 — and I decided to learn the language more. That was probably an important point in my life: a classical case of “programming is fun again”. I became interested and learned many new programming languages that year. Now I enjoy programming especially in Python in my research work.
Another important step was last year when I started contributing to CPython. With more understanding came more appreciation of the language design and
implementation. It is a pleasure to work with CPython code.
What other programming languages do you know and which is your favorite?
I played with around a dozen programming languages, but my favorite among mainstream languages is probably C (after Python of course). Also from less popular I should point out Forth, Scheme, and Haskell. I think these three influenced a lot my programming philosophy and style.
What projects are you working on now?
I am interested in static typing in Python. I co-authored PEP 483: The theory of type hints, worked on PEP 484: Type hints, and co-authored and implemented PEP 526: Syntax for variable annotations. Static vs dynamic typing is typically considered a “dangerous” topic, since people tend to be polarized in opinions. But I like that Python has chosen a wise way to add an expressive type system while making it completely optional and gradual. Namely, one can annotate only part of the code and use a special type “Any“ to combine static and dynamic typing virtually seamlessly. This approach contrasts type declarations in more static languages like Java or C# and is closer to how it is done in Racket, Erlang, and TypeScript. One can view type hints as a way to provide structured type metadata to third party tools, or a way to write automatically verifiable documentation that accompanies docstrings. Type hints could also potentially be used for optimizations, but it is not the main direction now.
Now I am mostly focused on mypy, one of the popular Python static type checkers. In particular right now I am working on adding support for structural subtyping (a.k.a. “static duck typing” or protocols or interfaces). Also I have started working on com2ann, a small library for automatic translation between type comments and type annotations. Type comments were added because of lack of syntactic support for type annotations in earlier versions of Python. Only type comments are allowed in 2.7, and type comments are required to annotate variables prior to 3.6. The library already supports translation to PEP 526 variable annotations, more functionality will be added soon.
Finally, there is an open source project in computational genetics to which I am going to come back later.
Which Python libraries are your favorite (core or 3rd party)?
I would name “typing“ (for obvious reasons), “pickle“ that I find very simple yet useful to save some arbitrary data for later exploration or processing, “collections“ provide several handy data structures that I use frequently (for example “defaultdict“, “Counter“, “ChainMap“).
Among third party my favorites are numpy and matplotlib. I use them a lot in my work, and I am very happy with them.
Where do you see Python going as a programming language?
I think three main directions where Python will be applied the most in the following decade are:
- Where science and programming meet: In recent years, many areas at the boundary between science and IT received a great boost, including big
data and machine learning. Python is a great tool for interactive exploration of semi-structured data that dominates real world. Taking into account lots
of handy numeric libraries and frameworks like numpy, pandas, scikit-learn, theano etc. one could see that Python is perfectly fit for these areas.
- Programming for non-programmers: Programming is becoming the new literacy, it penetrates the areas where it was unthinkable few decades ago: music,design, etc. Python is very readable, is easy to learn for beginners, and is oriented to put the programmer (not computer) at the first place. Therefore, I think this direction will be very prominent soon.
- Large polyglot projects: In modern programming world, people use right tools for a given problem more and more. Python is very modular and extensible and plays well with other languages. C API and dynamic nature helps a lot with this. As well traditions in the community encourage modularity and flexibility instead of rigidity. For example, asynchronous layer is not built-in into language but “pluggable”, type system is pluggable, an infrastructure for pluggable JITs is being developed, etc.
These are probably the most important directions in general for programming now. And I believe Python will lead in these directions.
Is there anything else you’d like to say?
I am new to the open source development (around two years), but it has been a really great experience to work in Python community. I had a very warm welcome, I receive a lot of appreciation and trust as well. Python is a cool language, but community and culture formed around it are essential parts of Python’s success.
Thanks for doing the interview!