Skip to main content

No project description provided

Project description

f_it

Iterator class for functional-esque, postfix-chaining programming.

Features

  • A single wrapper class exposing chain-able methods for lazily transforming iterators
  • Wraps functions from functools, itertools, and some extras
  • Optionally has a length, which is calculated for subsequent operations if possible

Note that this package is for convenience/ interface comfort purposes and does not provide the guarantees of a true functional language. There may be a significant performance overhead to using deeply nested FIt instances in tight loops.

Usage

from f_it import FIt

it = FIt(range(10))
transformed = it.map(  # cube elements
    lambda x: x**3
).filter(  # drop even elements
    lambda x: x % 2
).cycle(  # repeat the whole iterator 3 times
    3
).islice(  # take some elements from the middle
    5, 10
).chain(  # add 0-4 to the end
    range(5)
).chunk(  # separate into 2-length chunks
    2
)

# __add__ and __radd__ are implemented for chaining other Iterators
added = transformed + iter([1, 2, 3])

# nothing has been evaluated yet!

# evaluate operations, reading into a list
# if tqdm is available, show progress bar
as_list = added.progress().to(list)

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

f_it-0.6.1.tar.gz (14.7 kB view details)

Uploaded Source

Built Distribution

f_it-0.6.1-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file f_it-0.6.1.tar.gz.

File metadata

  • Download URL: f_it-0.6.1.tar.gz
  • Upload date:
  • Size: 14.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

File hashes

Hashes for f_it-0.6.1.tar.gz
Algorithm Hash digest
SHA256 e57cd594760a875c3dfec984b22f4cfe6225deff24876c0c949a44d55a8265c6
MD5 912783f10d747f44efe61d7541ccbfea
BLAKE2b-256 1f0fefe3c062496dbf4323db1b74b0bd4b725486f6e2ea8c006faee2aa373468

See more details on using hashes here.

File details

Details for the file f_it-0.6.1-py3-none-any.whl.

File metadata

  • Download URL: f_it-0.6.1-py3-none-any.whl
  • Upload date:
  • Size: 9.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

File hashes

Hashes for f_it-0.6.1-py3-none-any.whl
Algorithm Hash digest
SHA256 42b996fc97f821309e0f5b17402ceb82a4b3e1fec08fdebf58d6aedaf543bf99
MD5 cafb805f36bc992845f0a7af69abb314
BLAKE2b-256 3801c7f309a582a13d20fa99e524a37c98dde2f3412e3c02bd15781be8454541

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page