Skip to main content

An implementation of namedtuple written in c for warp speed.

Tested against Python 3.4 and 3.5, and 3.6 as of 3084914245d2

Warp Speed

Time to go fast.

Setup

Use qualified imports so that we can tell which namedtuple we are using.

>>> from namedtuple import namedtuple as cnamedtuple
>>> from collections import namedtuple as stdnamedtuple
>>> from pickle import dumps, loads

Little numbers

Cute graphs

These operations scale with the number of fields.

Type creation from a string of field names.

Type creation from a string of field names.

Type creation from a sequence of field names.

Type creation from a sequence of field names.

Instance creation.

Instance creation.

Less cute numbers

These operations do not scale with number of fields.

std_inst is an instance of a collections.namedtuple created type with six named fields: a, b, c, d, e, and f.

c_inst is an instance of a cnamedtuple.namedtuple created type with six named fields: a, b, c, d, e, and f.

Field Access
In [1]: %timeit std_inst.c
10000000 loops, best of 3: 71.9 ns per loop

In [2]: %timeit c_inst.c
10000000 loops, best of 3: 38.4 ns per loop
Pickle Roundtrip
In [3]: %timeit loads(dumps(std_inst))
100000 loops, best of 3: 6.28 µs per loop

In [4]: %timeit loads(dumps(c_inst))
100000 loops, best of 3: 4.72 µs per loop

Contributing

The project is hosted on github.

Before submitting a patch, please make sure your Python code is PEP8 compliant and your c code is PEP7 compliant.

Contact

Please file all bug reports on github.

For questions or comments, feel free to email me at joe@quantopian.com

Release files for cnamedtuple 0.1.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cnamedtuple 0.1.6
File Size Uploaded
cnamedtuple-0.1.6.tar.gz 10.8 kB Details

Release files / cnamedtuple-0.1.6.tar.gz

Download URL cnamedtuple-0.1.6.tar.gz
Size 10.8 kB
Tags Source
SHA-256 checksum
How to use checksums
b7d8ea7c9135eb30ac098578a712be4c58c812214e281d4585c56a19d5f48aed
BLAKE2b-256 checksum
How to use checksums
7e2b204e958c214a28cccaae73831469859731bd47a201c614142eb19378bca7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.1.6 This release

1 release file

0.1.5

1 release file

0.1.4

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page