src.pydasa.structs.tools.memory =============================== .. py:module:: src.pydasa.structs.tools.memory .. autoapi-nested-parse:: Module memory.py =========================================== Module with utility functions for handling memory allocation in the Data Structures of *PyDASA*. *IMPORTANT:* based on the implementations proposed by the following authors/books: #. Algorithms, 4th Edition, Robert Sedgewick and Kevin Wayne. #. Data Structure and Algorithms in Python, M.T. Goodrich, R. Tamassia, M.H. Goldwasser. Functions --------- .. autoapisummary:: src.pydasa.structs.tools.memory.alloc_slots Module Contents --------------- .. py:function:: alloc_slots() Decorator that converts a class into a dataclass with slots for memory optimization. This decorator uses Python 3.10+ native slots support in dataclasses to reduce memory usage by preventing the creation of `__dict__` for each instance. :raises TypeError: If the decorated object is not a class type. :raises RuntimeError: If the Python version is less than 3.10. :returns: Decorated class as a dataclass with slots. :rtype: Callable Example:: # Simple usage - all fields slotted, no dynamic attributes @alloc_slots() class Point: x: int y: int # Works with existing dataclasses @alloc_slots() @dataclass class Vector: x: float y: float z: float