No project description provided
גamla is a performant functional programming library for python which supports
pip install gamla
Debugging anonymous compositions
gamla.compose(x, y, z) produces a new function which doesn't have a proper name. If
x raises an exception, it is sometimes hard to figure out where this occurred. To overcome this, set the env variable
GAMLA_DEBUG_MODE (to anything) to get more useful exceptions. This is turned on only by flag because it incurs significant overhead so things might get slow.
Mixing asynchronous and synchronous code
Most functions in this lib will work seamlessly with
async and regular functions, and allow the developer to focus on the logic instead of deciding where to place an
import asyncio import gamla def increment(i): return i + 1 async def increment_async(i): asyncio.sleep(1) return i + 1 async def run(): mixed_composition = gamla.compose_left(increment, increment_async, increment) return await mixed_composition(0) # returns 3!
The main problems -
toolz is slow and does not support
Why is it slow?
It uses the expensive
inspect module to look at a function’s arguments, and doing so at each run. This happens not only on curried functions, but in compositions as well.
gamla not suffer from this problem?
- It does no longer support binary signatures on things like
map, so it doesn’t need to infer anything (these are higher order functions in
gamla.curryfunction pays for the signature inspection in advance, and remembers its results.
Function mapping and common gotchas (written in blood):
gamla.$1(make sure the call is with a single argument)
toolz.filter(None) -> gamla.filter(gamla.identity)
toolz.excepts(a, b, c)->
gamla.excepts(a, c, b)
gamla.excepts(a, gamla.just(None), b)(following the “data-last” currying convention)
Releasing a new version
- Create a pypi account.
- Download twine and give it your pypi credentials.
- Get pypi permissions for the project from its owner.
python setup.py sdist bdist_wheel; twine upload dist/*; rm -rf dist;
Release history Release notifications | RSS feed
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size gamla-50-py3-none-any.whl (276.6 kB)||File type Wheel||Python version py3||Upload date||Hashes View|
|Filename, size gamla-50.tar.gz (23.1 kB)||File type Source||Python version None||Upload date||Hashes View|