Can't subclass scene.Rect in 1.6 Beta
In Pythonista 1.5, I was able to subclass from scene.Rect. In the Beta, I can no longer do this. I get the following error:
TypeError: Error when calling the metaclass bases. type 'Rect' is not an acceptable base type.
A quick Internet search on this error did not yield anything intelligible to me. I bet there is a good reason I'm getting this error now, but I'm not clear on what it is.
The geometry types are now implemented in C instead of pure Python (as they were previously). That's not to say that I couldn't make them subclassable, but frankly, I don't think it would be a good idea because the behavior would likely be different from what you'd expect.
The thing is that internally, all the Node, Scene, Action etc. classes that deal with Points, Rects, and Sizes don't actually store them as Python objects, but as primitive structs (which are very fast to read from C code). When you assign to the position property for example, you can use any sequence of two numbers, be it a list, tuple, or Point object. The setter converts it to a struct internally, and when you read the attribute the next time, you'll always get a fresh Point object that is created on-the-fly.
This mechanism results in significant performance benefits because the renderer doesn't have to convert between Python objects and C structs all the time, but obviously, it wouldn't really work with subclasses because the actual Python object that you assign to an attribute is essentially thrown away.
OK, I can work with that. Yes, the performance benefit is worth it. Thanks!