Implements
forward-oriented programming
in Python. This shares configuration arguments across multiple components
and determines their values after the main business logic.
Dependencies: makefun
Developer: Emmanouil (Manios) Krasanakis
Contant: maniospas@hotmail.com
Features
- Adapt arguments to usage context
- Argument sharing between methods
- Speed up library development
- Easy adoption with decorators
Quickstart
Enable lazy execution and automatically annotate arguments with defaults as aspects:
from pyfop import lazy, autoaspects
@lazy
@autoaspects
def affine(x, scale=1, offset=0):
return x*scale + offset
Produce results with python code:
GM = (affine(2)*affine(8))**0.5
Set aspect values of previous code:
print(GM(scale=3)) # 12
Advanced features
Internal call of lazy methods while exposing their aspects.
@lazy
@autoaspects
def gm(x, y, affine=affine): # pass the method as an argument
return (affine(x)*affine(y))**0.5
GM = gm(2, 8)
print(GM(scale=3)) # 12
Print list of aspects.
print(GM.get_input_context(scale=3))
# context:
# - scale:
# value: 3,
# priority: Priority.HIGH
# shares: 1
# - offset:
# value: 1,
# priority: Priority.INCREASED
# shares: 4
Aspects are shared between everything contributing to the result.
@lazy
@autoaspects
def square(x, scale=1):
return scale*x*x
print(affine(2)(scale=2)) # 4
print((affine(2)+square(1))(scale=2)) # 5
Priority-based selection between defaults.
@lazy
def logpp(x, offset=Aspect(1, Priority.INCREASED)):
import math
return math.log(x+offset)/math.log(2)
result = affine(2)+log(3)
print(result(scale=2)) # 5+2=7
Toggle caching.
@lazy # automatically performs caching
def inc(x):
print("running")
return x+1
print(inc(2)())
# running
# 3
print(inc(2)())
# 3
print(inc(3)())
# running
# 4
@lazy_no_cache # disables caching
def inc(x):
print("running")
return x+1
print(inc(2)())
# running
# 3
print(inc(2)())
# running
# 3
print(inc(3)())
# running
# 4
Badge
Show usage of pyfop in your projects by adding the following badge to your README.md file:
[](https://github.com/maniospas/pyfop)
This will display the following:
Metadata
Release files for pyfop 0.3.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pyfop-0.3.5.tar.gz | 15.4 kB | Without provenance | Details for pyfop-0.3.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pyfop-0.3.5-py3-none-any.whl | Python 3 | none | any | Details for pyfop-0.3.5-py3-none-any.whl |
Total release size: 32.2 kB
Release files / pyfop-0.3.5.tar.gz
| Download URL | pyfop-0.3.5.tar.gz |
|---|---|
| Size | 15.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
59f781177284fe2a9050876cbf6f8a087d5e1fdd37340642cacf13f41d7f2098
|
|
BLAKE2b-256 checksum How to use checksums |
2de1a25684123be2a07468bcf08f76ca82f6c32796ef0ab5b988738604f4251a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.4
|
Release files / pyfop-0.3.5-py3-none-any.whl
| Download URL | pyfop-0.3.5-py3-none-any.whl |
|---|---|
| Size | 16.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
17de4ce501555dab04e1cdc971d2faae8d6591ae65754ae34e11433859557c3a
|
|
BLAKE2b-256 checksum How to use checksums |
daea26033545eac67d92ddb6bd73c486597fd86bd5260f10152acc6a3776e693
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.4
|
Security for pyfop 0.3.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.