News for hackers. Stuff that matters.
Re:Teaching how to code is broken by hexane360 on Friday January 14, 2022 @02:40PM (#29939285)
One way I've found is to dig into C/C++ extensions to Python. The Python C API reference is very helpful: https://docs.python.org/3/c-api/index.html

It can be quite fun to implement a simple data structure (tree, queue, etc.). in C and bind it to Python.

Otherwise, you can get a lot of dirty details by reading the source to complicated/magical libraries (e.g. pickle).

Re:Teaching how to code is broken by mynameismon on Saturday January 15, 2022 @06:42AM (#29945649)
I can confirm this works.

I was struggling to find why does a = [1, 2, 3] a = b b = b + [1] return a different value as compared to b += [1]

Looking into the source code, everything became clear. The + operator returns a pointer to a new list np containing all the elements from a and b, while += merely appends and returns a pointer to the original list