Skip to main content

pre-commit.ci status PyPI version Documentation Status

Functional, but Lazy Python

With FLPy, improve the readibility of your programs by leveraging functional programming.

Installation

FLPy has no external dependencies, and can be installed using pip:

pip install flpy

Examples

Given an input sequence x, print all, but the first, squared values that are divisible by 3 and collect the result into a list.

>>> x = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]  # Input sequence

# Usual way

>>> squares = map(lambda v: v * v, x)
>>> squares_div_by_3 = filter(lambda v: v % 3 == 0, squares)
>>> y = list(squares_div_by_3)[1:]  # We skip one value
>>> for v in y:
...     print(v)
36
81
>>> y
[36, 81]

# FLPy way

>>> from flpy import It

>>> y = (
...     It(x)
...     .map('|v| v * v')  # You can also use lambda or any other callable
...     .filter('|v| v % 3 == 0')
...     .skip(1)
...     .collect()  # Collects the iterator into a list
...     .for_each('|v| print(v)')  # Yet it still returns the list to `y`
... )
36
81
>>> y
ItA<[36, 81]>

TODOs

Non-exhaustive list of ideas.

  1. Implement parallel iterators
  2. Add kwargs support for built-in functions
  3. Increase # of examples
  4. Improve docs
  5. Write contribution guidelines
  6. Setup mypy
  7. Add unitary tests
  8. Add benchmarks vs. pure Python to measure overhead
  9. Add support for async iterators
  10. ...

Metadata

Release files for flpy 1.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for flpy 1.0.3
File Size Uploaded
flpy-1.0.3.tar.gz 2.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for flpy 1.0.3
File Interpreter ABI Platform
flpy-1.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 5.5 kB

Release files / flpy-1.0.3.tar.gz

Download URL flpy-1.0.3.tar.gz
Size 2.7 kB
Tags Source
SHA-256 checksum
How to use checksums
c8d62e7227fe3a9e66b532b6f00e9585b8b545d005f9d2cf25203e427d500ccf
BLAKE2b-256 checksum
How to use checksums
63eaae03090bab6c4693233f279804355b24a2b61a1625779359cafefa4db1c1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

Release files / flpy-1.0.3-py3-none-any.whl

Download URL flpy-1.0.3-py3-none-any.whl
Size 2.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e258b5f96b03daa7bdc7374a797f72d62c01ef89740a8fd441a6c37f42d43755
BLAKE2b-256 checksum
How to use checksums
b52bfa8ce100b495de1fa240af76a5969536d0890761793e72a4bf5b773a3d2f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

Release history Release notifications | RSS feed

This release

1.0.3 This release

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page