Skip to main content

Mutable variant of collections.namedtuple, which supports assignments

Project description

recordclass is MIT Licensed python library. It implements the type memoryslots and factory function recordclass in order to create record-like classes.

  • memoryslots is tuple-like type, which supports assignment operations.

  • recordclass is a factory function that create a “mutable” analog of collection.namedtuple.

This library actually is a “proof of concept” for the problem of fast “mutable” alternative of namedtuple.

Main repository for recordclass is on bitbucket.

Here is also a simple example.

Quick start:

First load inventory:

>>> from recordclass import recordclass, RecordClass

Simple example with recordclass:

>>> Point = recordclass('Point', 'x y')
>>> p = Point(1,2)
>>> print(p)
Point(1, 2)
>>> print(p.x, p.y)
1 2
>>> p.x, p.y = 10, 20
>>> print(p.x, p.y)
10 20

Simple example with RecordClass and typehints:

class Point(RecordClass):
   x: int
   y: int

>>> p = Point(1, 2)
>>> print(p)
Point(1, 2)
>>> print(p.x, p.y)
1 2
>>> p.x, p.y = 10, 20
>>> print(p.x, p.y)
10 20

Changes:

0.6

  • Add support for default values in recordclass factory function in correspondence to same addition to namedtuple in python 3.7.

0.5

  • Change version to 0.5

0.4.4

  • Add support for default values in RecordClass (patches from Pedro von Hertwig)

  • Add tests for RecorClass (adopted from python tests for NamedTuple)

0.4.3

  • Add support for typing for python 3.6 (patches from Vladimir Bolshakov).

  • Resolve memory leak issue.

0.4.2

  • Fix memory leak in property getter/setter

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

recordclass-0.6.tar.gz (19.6 kB view hashes)

Uploaded Source

Built Distributions

recordclass-0.6-cp37-cp37m-win_amd64.whl (24.3 kB view hashes)

Uploaded CPython 3.7m Windows x86-64

recordclass-0.6-cp37-cp37m-win32.whl (22.8 kB view hashes)

Uploaded CPython 3.7m Windows x86

recordclass-0.6-cp37-cp37m-macosx_10_9_x86_64.whl (22.4 kB view hashes)

Uploaded CPython 3.7m macOS 10.9+ x86-64

recordclass-0.6-cp36-cp36m-win_amd64.whl (24.3 kB view hashes)

Uploaded CPython 3.6m Windows x86-64

recordclass-0.6-cp36-cp36m-win32.whl (22.8 kB view hashes)

Uploaded CPython 3.6m Windows x86

recordclass-0.6-cp36-cp36m-macosx_10_9_x86_64.whl (22.4 kB view hashes)

Uploaded CPython 3.6m macOS 10.9+ x86-64

recordclass-0.6-cp35-cp35m-win_amd64.whl (21.2 kB view hashes)

Uploaded CPython 3.5m Windows x86-64

recordclass-0.6-cp35-cp35m-win32.whl (19.7 kB view hashes)

Uploaded CPython 3.5m Windows x86

recordclass-0.6-cp35-cp35m-macosx_10_6_intel.whl (25.9 kB view hashes)

Uploaded CPython 3.5m macOS 10.6+ intel

recordclass-0.6-cp34-cp34m-win_amd64.whl (18.8 kB view hashes)

Uploaded CPython 3.4m Windows x86-64

recordclass-0.6-cp34-cp34m-win32.whl (18.3 kB view hashes)

Uploaded CPython 3.4m Windows x86

recordclass-0.6-cp34-cp34m-macosx_10_6_intel.whl (25.8 kB view hashes)

Uploaded CPython 3.4m macOS 10.6+ intel

recordclass-0.6-cp27-cp27m-win_amd64.whl (19.0 kB view hashes)

Uploaded CPython 2.7m Windows x86-64

recordclass-0.6-cp27-cp27m-win32.whl (18.4 kB view hashes)

Uploaded CPython 2.7m Windows x86

recordclass-0.6-cp27-cp27m-macosx_10_9_x86_64.whl (19.3 kB view hashes)

Uploaded CPython 2.7m macOS 10.9+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page