Skip to content

drawing Fliq๐Ÿ”—

Fluent-syntaxed Lazily-evaluated Integrated Query.

build lint coverage

Python Versions PyPI - Version Downloads Ruff

Fliq is a lightweight Python library for high-performance lazy processing of iterables. Inspired by Django's ORM and LINQ, it provides a fluent syntax for lazily-evaluated operations on iterables, and it is tested to have on-par performance with the standard library. Also, for all you type-a-holics, Fliq is fully equipped with generic type hints, so it supports mypy in strict mode.

Installation๐Ÿ”—

pip install fliq
  • Fliq does not have any dependencies.
  • Fliq supports Python 3.9 and above.

Fliq is๐Ÿ”—

  • ๐Ÿ’ก Intuitive to use. Built for readability and usability. Fully typed.
  • ๐Ÿชถ Lightweight wrapper for the standard library. No dependencies or bloat.
  • โšก๏ธ Efficient as the standard library. Abstraction overhead is kept to a minimum.
  • โณ Lazy evaluated, executed only when needed and only as needed.
  • ๐Ÿ”— Versatile by supporting any iterable type, including infinite iterables.
  • ๐Ÿงฉ Compatible with APIs consuming iterables. No integration or setup required.

Motivation๐Ÿ”—

What is the output of the following code?

next(map(lambda x: x * 2, filter(lambda x: x % 2 == 0, [1, 2, 3, 4, 5])), -1)

And what about this?

from fliq import q

(q([1, 2, 3, 4, 5])
    .where(lambda x: x % 2 == 0)
    .select(lambda x: x * 2)
    .first(default=-1))

And this is just a simple example.

Python's standard library provides a rich set of functions for processing iterables. However, it is not always easy to read and use.

This is especially true when chaining multiple operations together. This is where Fliq comes in. Fliq provides a fluent, easy to read syntax for processing iterables, while keeping performance on-par with the standard library.

Performance๐Ÿ”—

Fliq is geared for performance:

  • ๐Ÿ›Œ It is lazily evaluated without requiring any intentional effort from the user.
  • โšก๏ธ It is also tested to have on-par performance with the standard library.

There are two mechanisms for checking Fliq's performance:

  • ๐Ÿงช Performance tests are ran on every commit, and they compare Fliq's performance to the standard library.
  • ๐Ÿ“Š Benchmarking is done against the standard library.

Here is a glimpse of the benchmarking results: Benchmarking

You can read more about Fliq's performance here.