Object-oriented programming (OOP) is the architectural foundation of Kimera Core. Every cache engine, serializer, and extractor in the library is built from a hierarchy of classes that share behaviour through inheritance, hide implementation details through encapsulation, and expose a uniform interface through polymorphism. Whether you are integrating Kimera Core into an application or writing a custom engine or handler, understanding these four principles — abstraction, inheritance, polymorphism, and encapsulation — will make the library’s design immediately readable and easy to extend.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/ismael-sarmiento/kimera_python/llms.txt
Use this file to discover all available pages before exploring further.
Abstract Base Classes
Python’sabc module provides two tools for expressing abstract contracts: the ABC base class and the @abstractmethod decorator. A class that inherits from ABC and declares one or more @abstractmethod methods cannot be instantiated on its own — attempting to do so raises a TypeError at runtime. Any concrete subclass must implement every abstract method before Python will allow it to be instantiated.
BaseCacheEngine
Declares the five cache operations —
get, set, delete, exists, clear — that every engine must implement.LocalCacheEngine
Extends
BaseCacheEngine with a further abstract method, size_regulator, and adds two concrete helpers: normalize_timeout and normalize_size.Extractor
Declares the single
read(**kwargs) method that all extractor implementations must provide.BaseSerializerHandler
Declares
can_i_handle_object_to_serialize, can_i_handle_object_to_deserialize, build_serializer, and build_deserializer — the contract every serializer handler must satisfy.ABCs enforce a contract at the class level, not just at the type-hint level. If a subclass forgets to implement even one
@abstractmethod, Python raises TypeError the first time the class is instantiated — not at import time. This makes mistakes visible immediately rather than at some distant runtime call site.Inheritance Hierarchy in Cache Engines
Kimera Core’s cache subsystem is built as a three-level hierarchy. Each level adds a focused layer of responsibility without repeating code from the level above.- BaseCacheEngine
- LocalCacheEngine
- InMemoryCacheEngine
- ThreadCacheEngine
The root abstract class. It defines
DEFAULT_TIMEOUT = 300.0 seconds and DEFAULT_SIZE = 300 elements as class-level constants, and it declares the five operations that every cache engine must support: get, set, delete, exists, and clear. It contains zero implementation logic.Polymorphism
Polymorphism lets one piece of code operate on objects of different types, as long as they all satisfy the same interface. BecauseInMemoryCacheEngine and ThreadCacheEngine both implement BaseCacheEngine, any function that accepts a BaseCacheEngine works unchanged with either engine — or with any future engine you write.
Encapsulation
Encapsulation hides implementation details behind a public interface, preventing external code from depending on internals that may change. Python signals private members with a leading underscore (_) for protected or __ (name-mangled) for strictly private.
Kimera Core uses both conventions deliberately:
_file_descriptors in RawZipExtractor
_file_descriptors in RawZipExtractor
RawZipExtractor.read() is the public entry point. The actual ZIP-reading logic lives in the static method _file_descriptors, which is an implementation detail. Callers should never call _file_descriptors directly — the underscore prefix is a clear signal that the method is subject to change.__serialize_object in serializer handlers
__serialize_object in serializer handlers
Each The public API is
BaseSerializerHandler subclass defines __serialize_object and __deserialize_object as name-mangled static methods. Because of Python’s name-mangling rules, DefaultSerializerHandler.__serialize_object is stored as _DefaultSerializerHandler__serialize_object, making it inaccessible from outside the class without a deliberate workaround.build_serializer and build_deserializer. Callers interact only with those methods; the conversion logic is fully encapsulated.Python Modules and Packages
Understanding how Python organises code into modules and packages is essential for navigating Kimera Core’s component layout.- A module is any
.pyfile. It defines a namespace and can be imported withimport. - A package is any directory that contains an
__init__.pyfile. It groups related modules and can export a curated public API through its__init__.py.
The leading underscore on
_pickle.py follows the same encapsulation convention used inside classes: it signals that _pickle is an internal implementation detail of the serializers package, not part of its stable public API. Import Pickle directly if you need it, but prefer KimeraSerializer for code that should remain portable.