pelper - python helper functions
Project description
pelper – python helper functions to ease measuring, ignoring, caching, …
pelper contains useful helper functions, decorators, context managers - all the stuff that make the python life a tiny bit easier. It has no dependencies, has a coverage of 100%, and is well documented.
Examples
Measure the duration of a function:
from pelper import print_duration
@print_duration()
def f(n):
pass
Measure duration of a context:
from pelper import print_duration
with print_duration():
range(4)
Ignore exceptions:
from pelper import ignored
with ignored(OSError):
raise OSError() # this is ignored
Cache already computed results of functions:
from pelper import cache
@cache
def fib(n):
return 1 if n < 2 else fib(n-1) + fib(n-2)
f(500) # this would run for quite a wile without the cache decorator
Pipe data through unix-like pipes
from pelper import pipe
pipe("some datat, some data",
set,
(sorted, {"reverse": True}))
Take n elements from iterables (useful if you can’t use the square bracket notation, e.g., if you’re using pipe)
from pelper import take
take(2, range(5))
Take the n-th elements from iterables (useful if you can’t use the square bracket notation, e.g., if you’re using pipe)
from pelper import nth
nth(2, range(5))
Installation
pelper is only one file and has no dependencies. You can simply drop pelper.py into your project and use it.
Run the tests:
python pelper.py
TODO
install via pip and conda
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
File details
Details for the file pelper-0.0.2.tar.gz
.
File metadata
- Download URL: pelper-0.0.2.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | eff70a90f0dc366de393d8a54847cebcb8ce76b4969cea6f4fa3a077d6d2483f |
|
MD5 | 5086f59ef6cfb4a1385e4f86b358b448 |
|
BLAKE2b-256 | 523037ef7ed9fc2c186faf82ccdeba31dc1400f713c390b59f7b8ccd140ba53a |
File details
Details for the file pelper-0.0.2.linux-x86_64.tar.gz
.
File metadata
- Download URL: pelper-0.0.2.linux-x86_64.tar.gz
- Upload date:
- Size: 5.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 05919cd3840f7d9e6c6fcaf62427420022a3a85cd50cf06e9789385c36ad2085 |
|
MD5 | 75ef0309b141c34b96d05a918edba398 |
|
BLAKE2b-256 | 60fd327f2fc9899ea4ee602a609ff60b9e8c43ab2a8b03790817d26e53352193 |
File details
Details for the file pelper-0.0.2-py2.7.egg
.
File metadata
- Download URL: pelper-0.0.2-py2.7.egg
- Upload date:
- Size: 7.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ee168129ecada5bf74c4ab23371d43f878d483845f5844613d51d463d644b1a0 |
|
MD5 | 67c1a87a8bd305ae70b2547320d95c58 |
|
BLAKE2b-256 | 01eab8be55931cc6112968edf287d9f0e5269f6713b2bc8d10a21d2b13cfb90d |