Skip to main content

Python binding of cedar (implementation of efficiently-updatable double-array trie) using Cython

Project description

pycedar

version python license

Python binding of cedar (implementation of efficiently-updatable double-array trie) using Cython

Official URL of cedar: http://www.tkl.iis.u-tokyo.ac.jp/~ynaga/cedar/

Installation

install from PyPi release

$ pip install --user pycedar

install from GitHub master

$ pip install --user https://github.com/akivajp/pycedar/archive/master.zip

Usage

using python-like dict class based on double array trie

>>> import pycedar

>>> d = pycedar.dict()
>>> print( len(d) )
0
>>> print( bool(d) )
False
>>> print( list(d) )
[]

>>> d['nineteen'] = 19
>>> d.set('twenty', 20)
>>> d['twenty one'] = 21
>>> d['twenty two'] = 22
>>> d['twenty three'] = 23
>>> d['twenty four'] = 24

>>> print( len(d) )
6
>>> print( bool(d) )
True
>>> print( list(d) )
['nineteen', 'twenty', 'twenty four', 'twenty one', 'twenty three', 'twenty two']
>>> print( list(d.keys()) )
['nineteen', 'twenty', 'twenty four', 'twenty one', 'twenty three', 'twenty two']
>>> print( list(d.values()) )
[19, 20, 24, 21, 23, 22]
>>> print( list(d.items()) )
[('nineteen', 19), ('twenty', 20), ('twenty four', 24), ('twenty one', 21), ('twenty three', 23), ('twenty two', 22)]
>>> print( d['twenty four'] )
24
>>> print( 'twenty four' in d )
True
>>> del d['twenty four']
>>> print( 'twenty four' in d )
False
>>> try:
>>>     print( d['twenty four'] )
>>> except Exception as e:
>>>     print( repr(e) )
KeyError('twenty four',)
>>> print( d.get('twenty three') )
23
>>> print( d.get('twenty four') )
-1
>>> print( d.get('twenty four', None) )
None

>>> print( list(d.find('')) )
[('nineteen', 19), ('twenty', 20), ('twenty one', 21), ('twenty three', 23), ('twenty two', 22)]
>>> print( list(d.find('tw')) )
[('twenty', 20), ('twenty one', 21), ('twenty three', 23), ('twenty two', 22)]
>>> print( list(d.find('twenty t')) )
[('twenty three', 23), ('twenty two', 22)]
>>> print( list(d.find_keys('twenty')) )
['twenty', 'twenty one', 'twenty three', 'twenty two']
>>> print( list(d.find_values('twenty')) )
[20, 21, 23, 22]

>>> n = d.get_node('twenty')
>>> print( n )
'twenty'
>>> print( repr(n) )
pycedar.node(trie=<pycedar.str_trie object at 0x7fffe2394b80>, id=260, length=6, root=0)
>>> print( n.key() )
twenty
>>> print( n.value() )
20
>>> print( [n.key() for n in n.find_nodes(' t')] )
[' three', ' two']

>>> n = d.get_node('twenty ')
>>> print( n )
None

>>> d.save('test.dat')
>>> d2 = pycedar.dict()
>>> print( d2.setdefault('eighteen', 18) )
18
>>> print( list(d2.items()) )
[('eighteen', 18)]
>>> d2.load('test.dat')
>>> print( list(d2.items()) )
[('nineteen', 19), ('twenty', 20), ('twenty one', 21), ('twenty three', 23), ('twenty two', 22)]
>>> print( d2.setdefault('eighteen', 18) )
18
>>> print( list(d2.items()) )
[('eighteen', 18), ('nineteen', 19), ('twenty', 20), ('twenty one', 21), ('twenty three', 23), ('twenty two', 22)]

using more primitive data structures

(TBA)

todo

  • documentation of classes:
    • base_trie
    • str_trie
    • bytes_trie
    • unicode_trie
    • node

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

pycedar-0.1.3.tar.gz (16.5 kB view details)

Uploaded Source

Built Distributions

pycedar-0.1.3-cp37-cp37m-manylinux1_x86_64.whl (741.1 kB view details)

Uploaded CPython 3.7m

pycedar-0.1.3-cp37-cp37m-manylinux1_i686.whl (687.1 kB view details)

Uploaded CPython 3.7m

pycedar-0.1.3-cp37-cp37m-macosx_10_15_x86_64.whl (179.1 kB view details)

Uploaded CPython 3.7m macOS 10.15+ x86-64

pycedar-0.1.3-cp36-cp36m-manylinux1_x86_64.whl (755.6 kB view details)

Uploaded CPython 3.6m

pycedar-0.1.3-cp36-cp36m-manylinux1_i686.whl (706.8 kB view details)

Uploaded CPython 3.6m

pycedar-0.1.3-cp36-cp36m-macosx_10_14_x86_64.whl (184.0 kB view details)

Uploaded CPython 3.6m macOS 10.14+ x86-64

pycedar-0.1.3-cp35-cp35m-manylinux1_x86_64.whl (707.3 kB view details)

Uploaded CPython 3.5m

pycedar-0.1.3-cp35-cp35m-manylinux1_i686.whl (652.3 kB view details)

Uploaded CPython 3.5m

File details

Details for the file pycedar-0.1.3.tar.gz.

File metadata

  • Download URL: pycedar-0.1.3.tar.gz
  • Upload date:
  • Size: 16.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.9

File hashes

Hashes for pycedar-0.1.3.tar.gz
Algorithm Hash digest
SHA256 bbb751939862cb3dfca1665724dfd960c150a4ba4a50b75a4301893df51ffadb
MD5 b41993030e77fbcf74a6a038df456eb9
BLAKE2b-256 caf8188f7368d4a10ddfafee4b29e5b7ffed28822f560d15d62bb6c425fd896e

See more details on using hashes here.

File details

Details for the file pycedar-0.1.3-cp37-cp37m-manylinux1_x86_64.whl.

File metadata

  • Download URL: pycedar-0.1.3-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 741.1 kB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.9

File hashes

Hashes for pycedar-0.1.3-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 77e883b04d5faffceb5e3201f7224f79b417494924986359ea4f82aab2fba21d
MD5 444b20330133b94f78d5e682bf01b5dd
BLAKE2b-256 cd31261d70c8976a6ead9303676c684e440f1d99b9cefa03c7553d52ee590bd5

See more details on using hashes here.

File details

Details for the file pycedar-0.1.3-cp37-cp37m-manylinux1_i686.whl.

File metadata

  • Download URL: pycedar-0.1.3-cp37-cp37m-manylinux1_i686.whl
  • Upload date:
  • Size: 687.1 kB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.9

File hashes

Hashes for pycedar-0.1.3-cp37-cp37m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 32f96ab018fed1864b8e7d14b1d74d89d4221219af05cad274401ba8d228d68a
MD5 6c2f8f0c31e313c68730184e5546a670
BLAKE2b-256 76fe2b9527d09cbbda887742808652bce6213116d3f775c58c2d481ff6d54647

See more details on using hashes here.

File details

Details for the file pycedar-0.1.3-cp37-cp37m-macosx_10_15_x86_64.whl.

File metadata

  • Download URL: pycedar-0.1.3-cp37-cp37m-macosx_10_15_x86_64.whl
  • Upload date:
  • Size: 179.1 kB
  • Tags: CPython 3.7m, macOS 10.15+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.9

File hashes

Hashes for pycedar-0.1.3-cp37-cp37m-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 814a90c629bd6e10772c797b7be1e088fd8829bd1d89f80932b5886b527d0cf3
MD5 07241f163466814e63c4c42e2103e16d
BLAKE2b-256 c32d5aa518b4f9548289ccf6ffd63ef7862c458bc155b9346be3cf7f82337587

See more details on using hashes here.

File details

Details for the file pycedar-0.1.3-cp36-cp36m-manylinux1_x86_64.whl.

File metadata

  • Download URL: pycedar-0.1.3-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 755.6 kB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.9

File hashes

Hashes for pycedar-0.1.3-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 71a6b6fdbff83484932ae5865e2777b718d757f77e9941b1e1160e9869c65c94
MD5 b95417a5d092a08e0d7b3ae6a2b799a6
BLAKE2b-256 28e14c252b963ed4e062ae6da4e7369f6f56b9e973878c5d031a5357930ede4f

See more details on using hashes here.

File details

Details for the file pycedar-0.1.3-cp36-cp36m-manylinux1_i686.whl.

File metadata

  • Download URL: pycedar-0.1.3-cp36-cp36m-manylinux1_i686.whl
  • Upload date:
  • Size: 706.8 kB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.9

File hashes

Hashes for pycedar-0.1.3-cp36-cp36m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 4f3299d75350bcf22789a9b9ffcacc36e28ddd0840f22bfa38846d0aa5ddfb6e
MD5 f4594c471aca5e07687bb096c62ce73b
BLAKE2b-256 3bacd4383f6c857d565afa3d9b5381d8edac9e690d26e1caa5188c9a456f6336

See more details on using hashes here.

File details

Details for the file pycedar-0.1.3-cp36-cp36m-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: pycedar-0.1.3-cp36-cp36m-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 184.0 kB
  • Tags: CPython 3.6m, macOS 10.14+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.9

File hashes

Hashes for pycedar-0.1.3-cp36-cp36m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 f3a0ff3c30338f6df7aec73a5249a92121c9ba0edf25e81154ac0bc6e38bd5ac
MD5 351cfc8fa1b4e8be58c2a47e064e6442
BLAKE2b-256 95f4633df12fa9d8df0fbdc2e85c69321a9b74c479887176e87e07402243d1f1

See more details on using hashes here.

File details

Details for the file pycedar-0.1.3-cp35-cp35m-manylinux1_x86_64.whl.

File metadata

  • Download URL: pycedar-0.1.3-cp35-cp35m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 707.3 kB
  • Tags: CPython 3.5m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.9

File hashes

Hashes for pycedar-0.1.3-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 d3ccae6c11a495cfa51cca08adc700aa7dba44ab021f0eca061fbf373bf643b1
MD5 ae73c8db1a93c8f62a5854b3e8e764c9
BLAKE2b-256 6beaaa1dd33fc04a0edf40311e3ace324f3e50dfabac65da8865361ef49601d4

See more details on using hashes here.

File details

Details for the file pycedar-0.1.3-cp35-cp35m-manylinux1_i686.whl.

File metadata

  • Download URL: pycedar-0.1.3-cp35-cp35m-manylinux1_i686.whl
  • Upload date:
  • Size: 652.3 kB
  • Tags: CPython 3.5m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.9

File hashes

Hashes for pycedar-0.1.3-cp35-cp35m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 131f42067c10efe9d3650a2c471d7911d6a9a98e2bc04dd952e4076b08773530
MD5 c632c22ea56d12b9a4798cc2506cc0fd
BLAKE2b-256 85aa61528b402d4f34719fda116901d5faee45aee46a4cc7ae58c08c40067c69

See more details on using hashes here.

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