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.2.tar.gz (149.4 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pycedar-0.1.2-cp37-cp37m-manylinux1_x86_64.whl (740.4 kB view details)

Uploaded CPython 3.7m

pycedar-0.1.2-cp37-cp37m-manylinux1_i686.whl (686.3 kB view details)

Uploaded CPython 3.7m

pycedar-0.1.2-cp37-cp37m-macosx_10_15_x86_64.whl (178.3 kB view details)

Uploaded CPython 3.7mmacOS 10.15+ x86-64

pycedar-0.1.2-cp36-cp36m-manylinux1_x86_64.whl (754.8 kB view details)

Uploaded CPython 3.6m

pycedar-0.1.2-cp36-cp36m-manylinux1_i686.whl (706.1 kB view details)

Uploaded CPython 3.6m

pycedar-0.1.2-cp36-cp36m-macosx_10_14_x86_64.whl (183.2 kB view details)

Uploaded CPython 3.6mmacOS 10.14+ x86-64

pycedar-0.1.2-cp35-cp35m-manylinux1_x86_64.whl (706.5 kB view details)

Uploaded CPython 3.5m

pycedar-0.1.2-cp35-cp35m-manylinux1_i686.whl (651.5 kB view details)

Uploaded CPython 3.5m

File details

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

File metadata

  • Download URL: pycedar-0.1.2.tar.gz
  • Upload date:
  • Size: 149.4 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.2.tar.gz
Algorithm Hash digest
SHA256 3390ffbb74fbc7a2815349cc3335aaf9bfd3f9595b7a9fd87769505146fa9390
MD5 d6551207717f3b2f548a5e4ac04d75d1
BLAKE2b-256 394ee4a04e9e0d55aa042befbf8c25a84bb441398d0ee9716ebafafcaca78bf8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pycedar-0.1.2-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 740.4 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.2-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 d645225f40b07af508d3b588be53c3981a6f31052dec3cbf05821ca12423e616
MD5 6d1f303897378e65f78c42658b826617
BLAKE2b-256 f0b2327e3f5976a3fe2d9441df50e149877f5f44fe0c1c025dd4d1b3468111c2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pycedar-0.1.2-cp37-cp37m-manylinux1_i686.whl
  • Upload date:
  • Size: 686.3 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.2-cp37-cp37m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 246f950849742a81146a45ea77864fbc3accf5086b418c3b61f4a49814961770
MD5 137254c9b1632ce01615d8fe5d53982b
BLAKE2b-256 8e6864da2c6db6f8d1064a1270836b8e3bdd4b0272a4afdd9e4b34a43cf2cf82

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pycedar-0.1.2-cp37-cp37m-macosx_10_15_x86_64.whl
  • Upload date:
  • Size: 178.3 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.2-cp37-cp37m-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 925e3c62888c1258b1376da4e0ce411d47be2e1b10abb9e52eabfa6363bafb32
MD5 a78d055e8706d5b2bc1a889a50b2b36d
BLAKE2b-256 ac762a116c26d6f3cb1a2998b2cb32905b81e0aec00027b86555752f2b82e05e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pycedar-0.1.2-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 754.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.2-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 3dab33d11e3a757365564e76797ad80c6d9d0076209303d6e4fa3a1cfed64bbb
MD5 bdefc9142e049e298d05f3361217617c
BLAKE2b-256 d22b88a9c14c5808ed0e1672acd07a7395a3e9a7594471aa37c94c4a1e883093

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pycedar-0.1.2-cp36-cp36m-manylinux1_i686.whl
  • Upload date:
  • Size: 706.1 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.2-cp36-cp36m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 d91b1a2c3b7176ddee6d08541b304d60cbcfbe3646af933932211464048160b0
MD5 b1c504c7f12ab6f6a24be03acd6f5df2
BLAKE2b-256 72422d2ead427b1af900d7b0062bf11fdc70ec71e674480f073e85a296d2e471

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pycedar-0.1.2-cp36-cp36m-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 183.2 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.2-cp36-cp36m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 d81866c14602c579f55b5cb1070738454bee464b3e50e77e3da9bcc92dc4844c
MD5 3e6752980af06451464a557cc7c0c8c7
BLAKE2b-256 8d13fd610dcb5b9c2239dc82a65a36bc42ea9a8d63fee945c4f1dfa640b6709d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pycedar-0.1.2-cp35-cp35m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 706.5 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.2-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 a644249c02fed97bb7b102c192c01bda197f129556d7d1b39cfe8f76ce634905
MD5 73fb09d919c22eb789290c6b7201eb82
BLAKE2b-256 07348f1983cf87c58f801565b3de0548ab175a048acacd567cfb0b89fdf2f32d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pycedar-0.1.2-cp35-cp35m-manylinux1_i686.whl
  • Upload date:
  • Size: 651.5 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.2-cp35-cp35m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 4bebe7b8f26fd2eae11a3d0f8e4b9cf1ecf834efdfe60acc7c65d266f265abd7
MD5 364e784e8c6cddf1279cc6b465f27b61
BLAKE2b-256 771a41300c0984991221b3dcf6fae57bd5f7045967b04c65001b918f54c24589

See more details on using hashes here.

Supported by

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