|
|
|
|
|
by adamzwasserman
243 days ago
|
|
I will complain about the global object. Even though technically, everything in Python is an object, I feel strongly that programmers should avoid OOP in Python like the plague. Every object is a petri dish for state corruption. Thee is a very solid list of reasons to use pure functions with explicit passing wherever humanly possible, and I personally believe there is no comparable list of reason to use OOP.
* Stack-allocated primitives need no refcounting
* Immutable structures reduce synchronization
* Data locality improves when you pass arrays/structs rather than object graphs
* Pure functions can be parallelized without locks |
|
But OOP does not necessitate mutable state; you can do OOP with immutable objects and pure methods (except the constructor). Objects are collections of partially-applied functions (which is explicit in Python) that also conceal internal details within its own namespace. It is convenient in certain cases.