I don't often say this, but I miss something from C++ that I can't do in Python. What I miss is unions. I know they can be dangerous and aren't supported consistently across compilers, but damn it, they can occasionally be useful.
I'm working on a 4x4 matrix class (for 3D maths) as part of my Game Objects library. It's something I have done several times in C++, where I create a union of a two dimensional array and four Vector4 classes. That way the matrix is conceptually both a grid of numbers and four vectors, which allows for quite elegant code. For example if I have a CMatrix class that stores the transform for a spaceship and I want to move it forward 2 units, I might use code like this.
matSpaceship.vecTranslation += matSpaceship.vecHeading * 2.;
Which is nicely descriptive. I have something similar as part of my Python Matrix44 class; there are descriptive properties that return the appropriate row from the matrix as a tuple. So the equivalent spaceship code would be something like this.
spaceship_transform.translate += Vector3(spaceship_transform.heading) * 2
I find the extra step of having to create a new Vector3 object to be extra noise in the code, but it seems unavoidable. The reason I return an immutable object rather than a Vector3 is because changes to the vector wouldn't have any effect on the parent Matrix. But frankly, it would be nice if they did. I would like to write something like
spaceship_transform.translate.y += 1 to move the spaceship along the y axis. I considered getting it working with a proxy object for the matrix rows that caught changes and modified the parent matrix - which I'm sure would work, but it would introduce inefficiency to something that should be fast and lean.
I'm not suggesting having a union construct for Python - heaven forbid! But it does feel like a 'wart' in my Matrix class. And that kind of thing can keep me up at night. :-(