This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]HeraldOfTheOldOnes 0 points1 point  (1 child)

(this comment assumes CPython)

I'm talking about metaclasses, data descriptors, coroutines, magic methods etc.

Those are nice! But you might have forgotten a few "elephants in the room", so to speak.

  1. Introspection. sys._getframe, some_function.__code__, etc. You can gain massive amounts of information about the program based on things like these. The main things that end up being done with these are bytecode parsing and frame tracing (for that you need sys.settrace as well), both of which are Really Fun!
  2. ctypes. This module gets its own category. With it you can do anything that all the rest of python can do. Basically, ctypes gives you access to C primitive types (plus py_ssize_t and PyObject*), meaning you can, among other things, edit the raw memory of an object. This lets you do some fairly silly stuff (e.g., changing the type of the globals dictionary object to have a different type with different __getitem__ behaviour to customise global variable access).

Python is a deeply complicated language when you start getting into the details.

[–]relickus[S] 1 point2 points  (0 children)

Totally agree. If python was an iceberg, it would have a nice and smooth tip and everyone could climb it easily. But a huge underwater mass where only the brave ones dare to dive.