Socket
Socket
Sign inDemoInstall

hat-trie-python

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hat-trie-python

Python bindings for Tessil/hat-trie


Maintainers
1

hat-trie-python

Python wrapper for https://github.com/Tessil/hat-trie (MIT License)

It's still incomplete, not all functionality is supported. Sets are not implemented yet. Tested on Linux 2.7+, Windows 3.5+, MacOS 2.7+. It should work on Windows 2.7 also, however it's tricky to compile.

Install

  • pip install hattrie (requires Cython and a C++11 compiler)

Example usage:

from hattrie import HatTrieMap
htm = HatTrieMap()
htm[b"/foo"] = b"1"
htm[b"/foo/bar"] = b"2"
print(list(htm.longest_prefix(b"/foo"))) # returns [(b'/foo', b'1')]
print(list(htm.longest_prefix(b"/foo/baz"))) # returns [(b'/foo', b'1')]
print(list(htm.longest_prefix(b"/foo/bar/baz"))) # returns [(b'/foo/bar', b'2'), (b'/foo', b'1')]
print(list(htm.longest_prefix(b"/foo/bar/"))) # returns [(b'/foo/bar', b'2'), (b'/foo', b'1')]
print(list(htm.longest_prefix(b"/bar"))) # returns []
print(list(htm.longest_prefix(b""))) # returns []

Any Python object is supported as value, however only bytes are supported as keys.

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc