Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Hi! This is part 6 of my Python behind the scenes series. Each part of the series covers how some aspect of the language is implemented in the interpreter, CPython. This time we'll focus on the Python object system. You'll learn:

  - What Python objects and types are and how they are implemented.
  - What slots are and how they determine the behavior of objects.
  - How slots are related to special methods.
I'd be glad to get your feedback and answer your questions. Thanks!


I have a C background from graduate school and a Python background from my professional work, but I've never explored how Python is implemented in C until I came across one of your previous parts of this series.

I don't have any questions. I just wanted to let you know I think you do a fantastic job writing these up. The thinking process is very clear, and the resource links are well placed for followup research. High quality stuff, for sure.

Thanks for making these. I look forward to future installations.


Thanks, Ryan! The series is going on. Stay tuned!


Can i translate this series in Portuguese? I think that would help a lot of coders that i know, but they can't read english.


Off topic, but do the programmers you know that can't read English struggle using programming languages and libraries where the keywords, class, variable, and function names are primarily in English? I'm curious how beginning or ESL programmers manage. Are there ecospheres where they can manage using only their first languages?


There is a vast difference between people that don't fluidly read/speak English and people that can't be arsed to learn what the 20 English keywords mean a programming language might use.


20 keywords, but what about EscapeString, or SpringContextIntegrationTest? A program can use a lot of English words.


Easy, you would code it in your own language.

Here in Europe is quite common to be faced with programs where everything written in-house uses the local language, including comments, only the third party libraries use English.

I already had a couple of consulting gigs where what got me the deal was my knowledge of the specific (human) languages being used.


I've seen several coding conventions that prohibit the use of past perfect aspect in boolean query methods (e.g. `checked`) in favor of an explicit auxiliary verb (e.g. `didCheck`). Also sophisticated concepts frequently get transliterated. 20 might be a stretch but less than 1000 is not that impossible.


How does a cord for fleeing tell you anything about what it actually is?

Both of your examples bring very little meaning from their English definition. You just know a second definition in the context of programming, which is why you can deduce what it does.

The same applies to the people that don't fluidly speak the language.


I'm not a native English speaker, but most of what I read on a day-to-day basis is in English. And yet, whenever I see or hear the term "string", I associate it with "sequence of characters", not with "cord". Same goes for "thread", but even more strongly [1]

So I agree, you don't have to speak fluent English to be able to read and write programs. Knowledge of English grammar won't help (except for reading comments – if they exist...), and the vocabulary is small, specialized, and has little to do with colloquial language.

[1] Or should it be "...even stronger"? I don't think so, because it refers to the verb "goes", so it should be an adverb, right?


This is pretty common in Brazil, there is a lot of people that are able to master the syntax, but cannot fully understand an article in English. That's why I always recommend then to have at least invest a little in technical English, as the resources in Portuguese usually are scarce and outdated.


Variables and nouns are easy to translate. Sentence meaning is significantly harder.


Yes! Feel free to do that.


Are there people who would be interested in how Python works at the C level but can't read English easily?

I've encountered programmers who are not fluent in English (e.g., some of the audience of non-English StackOverflow) but they don't seem to be a curious type (for whatever reason)


> Are there people who would be interested in how Python works at the C level but can't read English easily?

They said that there might be because they know people who are interested in the subject but don’t speak English. So I don’t know why you are asking the question.


I’d say anyone curious would have learned English already.

(Before I get bashed for this, I speak 3 languages well and 4 more poorly, English is my third. It really isn’t a difficult language to learn when all American media and most of computing uses it.)


I work with Japanese developers who I would struggle to hold a basic conversation with in English. They're about as curious as anyone else you'd find here and do read similar articles - but in their own language. There's a whole world of articles and open source out there not available in English.

The link between language learning and curiosity sounds tenuous at best. I would also add that having access to media in a particular language doesn't mean a lot unless you're prepared to put some effort in. I know expats who've lived in Japan for 20 years and can only speak a few words of Japanese despite being surrounded by it everyday.


But enough about you. There are a lot of places where people aren’t exposed to English-spoken media even if they might consume American media (dubbing in particular).


If it's easy, good for you! But from what I've noticed English, with its complicated & chaotic grammar is not that easy for a lot of people around the world that have different 1st & 2nd languages.


Perfect English is difficult, but that's the case for nearly all native speakers too. English is nothing but fluid and fault tolerant though, useful communication still happens even with quite broken English.


I agree.

It is ok that my comment above is downvoted but It would nice to hear any counter arguments (it is hard for me to imagine a passionate programmer who can't learn English).


I'll give you two:

Language learning is difficult and your success with one language has a lot to do with what you speak natively. I've heard that Italian speakers for instance can pick up English with relative ease compared with someone who grew up speaking Japanese.

People also have different priorities in life. Past high school and university you've got a career and possibly a family to attend to. Finding enough time to learn another language would be a big ask for many.


The counter argument is that the GP literally said they know people who are interested but don’t speak English.


"would help" and "are interested" seems like different categories.


Awesome, thanks for this!

In the spring I’ll be teaching a graduate-level university course on how the Python compiler and tooling works, so I’ll be showing them your articles.


You should give a go at reading or recommending Anthony Shaw's excellent book[1] (or at the very least the free article on Real Python[2]).

1. https://realpython.com/products/cpython-internals-book/

2. https://realpython.com/cpython-source-code-guide/


This is a great series. Thank you for this.


This is great! There aren't enough references on Python internals, I find.

Not sure you're at all interested in going in this direction, but I (and likely many people) would be really interested in a similar explanation of NumPy internals.


There are some great videos on youtube, a little outdated but gold if you can find them. It's this guy who literally sits at his desk for an hour and a half straight and walks a class line by line through various parts of cpython2.7 - little outdated but was awesome. There are multiple parts.


I think you're talking about Philip Guo's lectures. They are great! Here's a playlist: https://www.youtube.com/playlist?list=PLzV58Zm8FuBL6OAv1Yu6A...


Yeah, these are great.


Please open a documentation issue at https://github.com/numpy/numpy/issues describing exactly which internals you would like to see explained: indexing, ufuncs, linkage, random, dtypes, ... and what format you would like to see the documentation in: text, video, lessons with questions/answers, ...

As for python internals, https://snarky.ca/ has some great short high level “how does this construct work” text explainations.


More people are looking for passive articles to consume than filing a bug report to request information on specific systems. This reply is unnecessary.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: