--- id: recordclass version: "0.24" license: The MIT License (MIT) Copyright (c) «2015-2023» «Shibzukhov Zaur, szport at gmail dot com» Permission is hereby granted, free of charge, to any person obtaining a copy of this software - recordclass… (full text in the JSON record) license_treatment: permissive maintenance: active --- # recordclass — Mutable variant of namedtuple -- recordclass, which support assignments, compact dataclasses and other memory saving variants. License: permissive · Maintenance: active · Downloads: 126.4K/mo ## What it is and what it does Recordclass is a library for creating lightweight, mutable record types in Python that avoid the memory overhead of standard dataclasses and namedtuples by opting out of cyclic garbage collection. It provides three main interfaces: a `recordclass` factory (namedtuple-like), a `dataobject` base class (dataclass-like), and lightweight container types (`litetuple`, `mutabletuple`) designed for scenarios where you are certain your objects will never participate in reference cycles. The library is built on a custom metaclass that skips the `PyGC_Head` prefix normally added to Python objects, reducing per-instance memory by 16–32 bytes depending on Python version. This is most useful for applications that create many small, short-lived objects with simple field types (int, float, str, date/time), such as coordinate records, scientific data points, or compact data structures in memory-constrained environments. The trade-off is that you must manually ensure no circular references are created; the library does not enforce this at runtime. Use it for: - Store millions of coordinate or vector records (x, y, z) in memory-intensive scientific or graphics applications. - Build compact data structures for machine learning feature vectors where memory footprint directly impacts cache performance. - Replace namedtuple in high-throughput data pipelines where object creation speed and size matter. - Create immutable or mutable tuple-like containers (litetuple, mutabletuple) for collections that will never form cycles. - Define strongly-typed record classes with type hints that consume less memory than standard dataclass instances. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Recordclass provides memory-efficient, mutable alternatives to namedtuple and dataclass by creating record types that skip Python's garbage collection overhead, reducing instance size by 16–32 bytes depending on Python version. Yes, if you are building memory-sensitive applications with many small objects and can guarantee no circular references. The active maintenance, permissive license, and support for modern Python versions (3.8–3.14) make it reliable. However, the high install friction (source compilation required) and narrow use case (only beneficial when memory overhead of PyGC_Head is a real bottleneck) mean it is not a general-purpose replacement for dataclass or namedtuple—install only when profiling shows memory is a constraint. ## Install pip install recordclass uv add recordclass poetry add recordclass ## Installing recordclass Before you install: Installation requires compilation from source (high friction). The package is actively maintained with recent commits and supports modern Python versions (3.8–3.14), but the build dependency may complicate deployment in restricted environments. License in practice: MIT License permits unrestricted use, modification, and distribution with minimal restrictions—suitable for both open-source and proprietary projects. Quickstart: from recordclass import recordclass, dataobject, astuple, asdict # Factory function Point = recordclass('Point', 'x y') p = Point(1, 2) p.y = -1 print(astuple(p)) # (1, -1) print(asdict(p)) # {'x': 1, 'y': -1} # Class-based class Coord(dataobject): x: int y: int c = Coord(3, 4) print(c.x, c.y) Requires a C compiler and Python development headers to build from source; pre-built wheels may not be available for all platforms. Verify before relying: - Whether pre-built wheels are available for common platforms or if source compilation is always required. - Actual memory savings in real-world applications compared to dataclass or __slots__ with typical field counts. - Whether the reference-cycle avoidance guarantee holds under all documented use patterns. ## Package facts - License: The MIT License (MIT) Copyright (c) «2015-2023» «Shibzukhov Zaur, szport at gmail dot com» Permission is hereby granted, free of charge, to any person obtaining a copy of this software - recordclass… (full text in the JSON record) (permissive) - Python support: supports_current - Install friction: high - Maintenance: active - Downloads: 126.4K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags mutable namedtuple, memory-efficient dataclass, lightweight record types, compact data structures, gc-free python objects, namedtuple alternative, slot-like classes, memory-optimization, data-structures, performance-tuning [View on SkillFed](https://skillfed.io/packages/recordclass) · [View on PyPI](https://pypi.org/project/recordclass/)