Interviews News

Interview with Luciano Ramalho, webinar presenter this Thursday

Python’s combination of power and simplicity has long been one of its key selling points. This includes its data model. Luciano Ramalho, who is our guest presenter for the next webinar, recently wrote about this in Fluent Python, an O’Reilly book widely considered one of the best recent books on Python.


There’s another well-known strength of Python: its community, and Luciano is one of those long-time key people who is warm, inviting, smart, and part of Python’s appeal. We’re lucky to have him with us for the last webinar before PyCon and decided to do a quick interview with him.

Give us a sneak peak on what you’re going to discuss in the webinar and what audience it is aimed at.

What makes an API “Pythonic”? That’s somewhat subjective, but we can learn a lot by looking at concrete examples like the built-in set types: set and frozenset. They “feel right” because they leverage some of Python’s strongest features. The set types are iterable, so they play well with core Python constructs and with powerful libraries like itertools. They also provide handy methods that consume iterables of other types, so you can compute the union of a set and a list, for example. And they leverage operator overloading, enabling concise coding of set expressions.

After covering the strengths of Python sets, I will show how to implement a new set class optimized for dense sets of integers. This talk will be accessible to anyone who knows how to write object-oriented code in Python.

This is part of what you evangelize in the book about the hidden beauty of Python’s data model. Can you explain more about that?

Once you know the basics, I believe anyone interested in mastering Python needs to learn about the Data Model: the set of core interfaces that make the language and standard library so consistent and so powerful.

For example, we expect any collection type in Python to be iterable, so that we can use it in for loops and with handy functions such as sorted, any, all, dropwhile etc. The Data Model specifies the interfaces you need to implement to build an iterable collection.

For debugging and testing, we want objects to be printable and comparable. Supporting operators such as + to join custom data structures? The Data Model explains how to do all of those things and more.

How are book sales and what was it like writing an O’Reilly book?

I was lucky because I decided to write an intermediate Python book when the language was growing faster than ever, and there were lots of basic books but not so many intermediate ones. So Fluent Python was O’Reilly’s best selling item the month after its release and has been going strong since then. It’s also been translated into 7 languages so far.

I’ve always been an avid consumer of O’Reilly books, so writing one for them was a dream come true. My editor, Meghan Blanchette, was excellent, and I could not have asked for a better team of tech reviewers: Alex Martelli, Anna Ravenscroft, Lennart Regebro, Leonardo Rochael, and Victor Stinner.

I also enjoyed writing the book in Asciidoc: I was a fan of RestructuredText, but Asciidoc has friendlier syntax and is better suited for book writing because it was designed to target DocBook, a publishing industry XML standard. You can render Asciidoc to HTML, ePub, PDF and other formats using Python tools, but the best toolset is Asciidoctor, written in Ruby.

Let’s go back in time. You and I became really good friends in the late 90’s, when Python was really taking off and you were the key person in Brazil. Can you give us your Python origin story?

For me, the best thing about getting involved with Python was making friends like you, Paul. I started doing Web development in 1994, using the most popular language for that purpose at the time: Perl. Before that, I had taught myself object-oriented programming with Smalltalk, but Perl did not have a strong OO culture and class libraries, even after Perl 5 came out.

In Perl forums, it was common for people to suggest looking at Python code for inspiration about how to design classes in a language that had more similarities with Perl than Smalltalk or C++ did. So I decided to check out that obscure language and fell in love as soon as a read the first chapter of Guido van Rossum’s tutorial. It seemed as elegant as Smalltalk, but with a more readable Algol-like syntax, and it was as practical as Perl.

In 1998 I started a company focusing on publishing systems for large-scale Web sites. I chose Python as our language, and I chose an even more obscure but incredibly advanced Web framework called Zope as the basis of our systems. Before that year was over, we had deployed a new publishing system for the most important Brazilian IT news portal at the time, and it became one of the first marketing cases for Zope worldwide. You were one of the makers of Zope, and that’s how our friendship started.

You historically have done a ton of teaching. What’s unique about Python as a teaching language?

Python is an awesome teaching language for several reasons. First, because it is a “real” language — not a toy — so people use it in many domains, and there are Python libraries for a lot of different domains. This is the reason why it replaced Scheme as the main language at MIT’s introductory programming classes.

Second, it is easy to learn because it has a simple syntax, very consistent semantics, and a fail fast philosophy: Python “refuses to guess” so it raises exceptions where other scripting languages fail silently or behave unexpectedly (looking at you, JavaScript, Perl, and PHP).

Third, Python’s interactive console is a great learning and exploration tool. IPython and Jupyter Notebooks make that even better. Now we have a virtuous cycle: as Python becomes more widely used for teaching, more teaching resources are available for it, like Philip Guo’s Python Tutor, programmable devices like the BBC micro:bit and Adafruit’s CircuitPython products, MOOCs, beginner’s books, academic textbooks, etc.

You’ve always been a language junkie and that’s accelerated recently. Based on that, what’s the next big thing for Python, and the next big thing outside of Python?

I learned about a dozen languages before Python, but I got a bit lazy to learn others because Python is so practical and fits my brain so well. I was very interested in Ruby around 2006, and a few times I’ve tried hard to like JavaScript, but failed. I became more interested in concurrency because of the success of Node.js. But JavaScript, Python, and Ruby are not ideal to tackle large-scale concurrency challenges. Yes, we can do efficient “IO bound” programming in these languages, but I’ve learned that IO bound systems become CPU bound as they grow: lots of small functions slow down the event loop, which slows down everything else. To deal with this, the language runtime must be able to spread the load over multiple CPU cores, so that no single slow function blocks all others. So I am very interested in languages that were designed from the start for concurrent programming. Right now, I am focusing on Go and Elixir.

The next big thing for Python seems to be type hinting and all the tooling it will enable. But I would be most excited if we got rid of the infamous GIL (Global Interpreter Lock), or found a way to work around it that’s mostly transparent to the user. However, the GIL makes writing Python extensions in other languages easier than it would be otherwise. And Python owes much of its popularity to the huge number of extensions people have written. So the GIL is like a deal we made with the devil. We had a lot of success… Can we walk away from that deal?

After Go and Elixir, I want to dive into Rust, but for a different reason: it seems to be a great language for writing Python extensions. I also want to try Cython. As long as the GIL is around, we might as well enjoy its benefits by writing more awesome extensions.

image description