More Data Structures
Project description
More Data Structures
More Data Structures or more-ds for short, provides simple and convenient Python data structures.
Data Structures
id
- SemVer
Class for easy creation of semantic version numbers.
network
- URL
Class for easy (unvalidated) URL construction.
time
- Timer
Context manager for timing a block of code.
Getting Started
% pip install more-ds
>>> from more_ds.network import URL
>>> base_url = URL("http://example.org/")
>>> api_url = base_url / "api"
>>> url = api_url / "ip" / "address" // dict(version=4)
>>> print(url)
http://example.org/api/ip/address?version=4
Or
from time import sleep
from more_ds.time import Timer
with Timer() as t:
# sleep for half a second
sleep(.5)
print(t.elapsed) # -> 0:00:00.501864
Or
>>> from more_ds.id import SemVer
>>> old = SemVer("v3.1.4")
>>> new = SemVer("3.2")
>>> old
SemVer("3.1.4")
>>> new
SemVer("3.2.0")
>>> old == new
False
>>> old < new
True
>>> old > new
False
>>> repr(old)
'SemVer("3.1.4")'
>>> repr(new)
'SemVer("3.2.0")'
>>> isinstance(old, str)
True
Origin
The projected started with the need to extract the simplest of classes from an existing open source library, nwa-stdlib. That library primarily contained code that was rather specific to the organization that created the library. However, the URL class was a tiny convenience data structure, with broader applicability, that took the chore out of programmatically creating URLs. By extracting that class into a separate project, one that is specifically focussed on convenient data structures, it hopefully attracts a broader set of users that would otherwise don’t feel comfortable including nwa-stdlib as a whole.
The project’s name was inspired by the wonderful More Itertools library.
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
Built Distribution
File details
Details for the file more-ds-0.0.6.tar.gz
.
File metadata
- Download URL: more-ds-0.0.6.tar.gz
- Upload date:
- Size: 13.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 931d6913beebcf9c4e8155b6b58eef3fc94f000c5b6fb838261b2c0c8886b69c |
|
MD5 | 60e3803c401d006d277590b5d597dd16 |
|
BLAKE2b-256 | 1c07188c20daff5349c65bfcebd3b972bb1def809724778f11e3744eda0933fd |
File details
Details for the file more_ds-0.0.6-py3-none-any.whl
.
File metadata
- Download URL: more_ds-0.0.6-py3-none-any.whl
- Upload date:
- Size: 15.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 777df5b01e3a492ccccd4058156e7d916013e02e85248a8b2c2ca1d1ab13789b |
|
MD5 | 3ecb150b78d43baaa90548d5cf92ae3e |
|
BLAKE2b-256 | b8d18054c137a20430adb73f269f120314956574f40d3317a3b0c7a19625d48e |