Skip to main content

Chemical

Rust-Style Iterators in Python!

Compose iterator sequences like chemical compounds!

Quickstart

>>> from chemical import it

>>> my_iter = it([1, 2, 3])
>>> my_iter.next()
1
>>> my_iter.next()
2
>>> my_iter.next()
3

>>> it('abc').map(lambda x: x.upper()).collect(str)
'ABC'

>>> it('abc').inspect(print).go()
a
b
c

>>> for num in it(range(100)).skip(10).take(10).rev().step_by(4):
...     print(num)
19
15
11

>>> # Same as above but written as an expression:
>>> it(range(100)).skip(10).take(10).rev().step_by(4).for_each(print).go()
19
15
11

>>> # Large Chemical compositions can span multiple lines using parentheses:
>>> (it(range(100)
...      .skip(10)
...      .take(10)
...      .rev()
...      .step_by(4)
...      .for_each(print)
...      .go()
... )
19
15
11

About

Chemical takes heavy inspiration from the iterators that can be found in the Rust Programming Language. Chemical provides composable, customizable, and powerful iterators that can be combined, chained, aggregated, and so much more.

Although Python has very powerful iterators already, Chemical provides a way to programatically compose them to create highly compact but comprehendible behaviors.

You can even add your own "traits" to the it class at runtime and they will be available for use anywhere in your program! This allows you to create custom functionality without having to use your own type derived from it.

Installation

$ pip install chemical

Chemical has been tested on:

  • Windows
  • MacOS
  • Linux
  • Python 3.6
  • Python 3.7
  • Python 3.8

To run the unit tests:

$ git clone https://github.com/Pebaz/Chemical
$ cd Chemical
$ pip install -r requirements.txt
$ pytest

Documentation

You can view the generated documentation here.

You can also look at the source code for more insight on how you can extend it to have more iterators and aggregators specific to your own application.

The unit tests also provide an abundant amount of examples as they cover every iterator/aggregator in Chemical.

Metadata

Release files for chemical 1.0.1

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

Source distribution (sdist)

Source distribution for chemical 1.0.1
File Size Uploaded Provenance Actions
chemical-1.0.1.tar.gz 11.6 kB Without provenance Details for chemical-1.0.1.tar.gz

Release files / chemical-1.0.1.tar.gz

Download URL chemical-1.0.1.tar.gz
Size 11.6 kB
Tags Source
SHA-256 checksum
How to use checksums
add70a5dbb3b28d7c88bba7d468ced7b07b3461ece351cfbce19fa033042536f
BLAKE2b-256 checksum
How to use checksums
4ff36f678ae297bfe30cf4433ae56551e6605e83b471631c45ff0a180459b27d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3

Security for chemical 1.0.1

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.

Release history Release notifications | RSS feed

This release

1.0.1 This release

1 release file No provenance

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