Atomic Values

Atoms are a special kind of data storage class in PySoy. Their purpose is to store small bits of related data, such as the channels of a Color or the dimensions of a Position, so that they can be updated, shared, and calculated correctly. Many of these types could be replaced with a Python list with a few math functions added. What makes them different is how they're handled internally.

These types are not actually used to store data on the backend, they're actually handles to backend data used to access and manipulate it. A Color object is not actually stored for Window.background, the Window type has its own RGB storage for background color internally, but when the background property is requested a Color object is created so the RGB storage can be worked with by the user. When the properties of the returned Color object change a Window callback is called to update its storage as well, as if Color was actually being used internally.

While this may seem like a lot of work to save a few kilobytes of data, consider that Color is used everywhere - including Textures. Imagine the memory bloat storing an object for every pixel of a texture, further the framerate hit we'd take from iterating over all those objects to render.

The purpose of atomic values is thus to speed up rendering/physics/sound and save memory while retaining familiar Object-Oriented behavior of values (even if that behavior is hacked somewhat).

Atomic Values live in the soy.atoms module.