by stevefan1999 · 2w ago · 0 comments
Okay, I will be the one to challenge you.
What do you think about https://docs.python.org/3/library/abc.html and how painful it is to work with?
What do you think about the (quite infamous) Method Resolution Order (MRO) and C3 linearization algorithm, which is, basically a topological sort over the inheritance chain IIRC? And I have a lot of mysterious package bugs are actually due to that breaking, like I used to have with ComfyUI.
But you know, I've worked with Python codebases before, and all those are painful to deal with. Don't get me started with the confusing aspect of **kwargs vs **args, although in JS there is a similar concept called arguments object (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...) and spread operator I think?
Oh, I still remember one particular hell that my team wrote scripts that directly add packages to PYTHONPATH. THE PYTHON FUCKING PATH.
The fact that you can directly append to sys.path is mindblowing and ridiculous to me. You can totally insert some malicious code to take over the program, so this is a huge cybersecurity issue. I tried to solve this by introducing Poetry (or is it PDM? I don't remember) to the team but nobody follows. Back then uv doesn't exist if I remembers, but the effort to "correct" (hell I don't even know if that is really correct or not) it is kinda futile.
As a DevOps that creates a huge dependency hell and I resigned soon after. Perhaps it is a cultural problem I don't want to drill on in too mcuh.
Okay, maybe something else more meta. The fact that Python wants to have duck types and traditional OOP is kind of like having a cake and eat it, you really can't have both, unless you have some form of mediators, like you have interface/protocol in C#/Java/Swift/Obj-C.
With Python, almost everything is a dynamic value, even with the new type hints facility. Same problem goes for JavaScript (and evolving it to a certain extent, TypeScript too).
I think that's one of the few banes of prototypical design I would say, that everything essentially becomes a hash table in live environment.
But I guess it is suffice to say, the legacy of Lisp really does live on.
I remember when MRO was discussed on comp.lang.python. It improved on the previous implementation. Because of that discussion I've worked to avoid diamond inheritance, with a preference for mixins.
I think you mean **kwargs and *args (with a single star)? (I'm assuming it was an HN formatting issue.) One of the annoying things about them is APIs which pass **kwargs around, uses a few of them, and pass the rest to the lower level API. It's really hard to document what the top-level function accepts when you don't know the whole call path.
Looking through my code I see I rarely use *kwargs. One of the exceptions is when I do a pass-through to a function I can't control, but where I want to add, for example, timing instrumentation. Another is for a base-type with a default "raise NotImplementedError" where the subclasses have subclass-specific parameters.
Anything which can add to sys.path can tweak the rest of the Python run-time.
>>> def my_len(*args, **kwargs):
... print("Hello!")
... return old_len(*args, **kwargs)
...
>>> old_len = len
>>> import builtins
>>> builtins.len = my_len
>>> import uuid
Hello!
Hello!
Hello!
Hello!
Now tie that in with some 'import traceback' and stack exploration.If you can change PYTHONPATH then you can change LD_LIBRARY_PATH. I've had to shim some programs that way.
If you want to find who is being naughty: sys.path = tuple(sys.path)
I primarily use duck-typing, with OO mostly for implementation reuse. I think of it more like C++ templates than Smalltalk-like OO. I hate dealing with type annotations. Some places I just use Any. I don't understand the fascination with them. One of the few places in Python where you need OO is with exception handling.
One of the guidelines for Python development in the 1990s was "it's for consenting adults". The "__hack" for semi-private members was not meant for actual information hiding. It sounds like that's not the environment you're in, which helps explain why it's not a good fit.
You left out gc pausing. I remember working for hours trying to understand spikes in my data, not being able to reproduce with just that test case, until finally disabling gc.
And you left out failed __del__ calls during shutdown because the Python interpreter is in a partially destroyed state and certain things you expect are simply gone. I've had to ensure every temporary filename in my test suite has a unique name so I could help track those down. (See, if gc runs earlier then the __del_ doesn't fail, so it needs just the right patterns of calls to trigger an error.)
Does all that make me a tribalist? Oh woe is me, how am I to maintain group cohesion with that sort of attitude? /s
But really, I don't understand why you posed your question or comments. Is it just to complain about your experience with Python, or does it have something more directly related to the essay's commentary on language wars and techno-tribalism?*