Skip to main content

FlpIt

📖 Documentation | 🌐 GitHub | 📦 PyPI

Fluent LINQ for Python — LINQ semantics, Python-native execution

FlpIt brings a strongly typed, LINQ-style API to standard Python iterables. It combines the fluent query model and semantics of .NET LINQ with Python's native iterable and generator model.

If you know C# LINQ, you already know most of FlpIt. Existing LINQ examples, query patterns and documentation can generally be translated directly, which makes the .NET LINQ ecosystem a valuable reference for developers and AI coding assistants alike.

Semantic goal: flp strives to faithfully reproduce .NET LINQ semantics. Where Python's language or type system requires a different API contract, the contract is adapted accordingly, and each deviation is documented. The implementation is actively developed, and further deviations may still exist.

💡 Quick Start

uv add flpit        # or: pip install flpit
from flpit import flp, FlpIt, FlpList

# A lazy, streaming pipeline: nothing has run yet.
query: FlpIt[int] = (
    flp.it(range(1, 11))
    .where(lambda x: x % 2 == 0)
    .select(lambda x: x * 10)
)

# Explicit materialization.
result: FlpList[int] = query.to_list()
# [20, 40, 60, 80, 100]

🤸 Flipping the Pipeline

Native Python functional operations read inside-out. A FlpIt pipeline reads in the order things happen:

# 🔁 Native built-ins
result = list(map(lambda x: x * 10, filter(lambda x: x % 2 == 0, range(1, 11))))

# 🤸 FlpIt pipeline
result = (
    flp.it(range(1, 11))
    .where(lambda x: x % 2 == 0)
    .select(lambda x: x * 10)
    .to_list()
)

⚡ What's in the Box

  • Lazy queries (FlpIt) and materialized lists (FlpList): deferred, streaming execution over any Iterable[T], with where, select, select_many, order_by, group_by, joins and the rest of System.Linq.Enumerable. Guide
  • Async queries (AsyncFlpIt): the IAsyncEnumerable<T> counterpart, with async callbacks, cancellation and cleanup. Docs
  • Faithful semantics: when work happens, how much is read, what comes out and how it fails match .NET, also when operators are chained. Derived queries never affect each other. Semantics
  • Typed JSON and CSV: dataclasses to and from JSON and CSV, with msgspec or a pure-Python backend. JSON, CSV
  • Task runtime: an asyncio-free runtime modelled on the .NET thread pool, with Task.when_all, continuations and cooperative cancellation. Docs
  • Channels, concurrent collections and threading primitives: Channel[T], ConcurrentDictionary, SemaphoreSlim and friends. Docs
  • Static-first typing: designed for precise pyrefly inference without plugins (mypy and pyright may give varying results).

FlpIt models in-memory LINQ (IEnumerable). It does not model IQueryable or expression trees.

⚙️ Installation

uv add flpit

msgspec is installed automatically on CPython. On other interpreters (PyPy, Pyodide) flpit installs without it and uses the native JSON backend. Free-threaded CPython 3.13t is not supported by msgspec: install there with --no-deps, or use 3.14t.

🧭 Like FlpIt? Give .NET a try.

Enjoying FlpIt's .NET-inspired programming model? Here's where it comes from: try C# in your browser, explore LINQ, or keep your Python and call it from .NET.

📜 License

Distributed under the MIT License. See LICENSE for more information.

Migrated .NET Unit Tests

Migrated from the official .NET Runtime LINQ Tests. Note: The test cases exercise both core types, FlpIt and FlpList, with transitions between lazy and eager execution occurring as part of the individual test cases. async_linq/ is migrated from the .NET 10 System.Linq.AsyncEnumerable tests and exercises AsyncFlpIt on the flpit task runtime. channels/ is migrated from the System.Threading.Channels tests; concurrent/ from the System.Collections.Concurrent tests, including the shared IEnumerable / ICollection / IDictionary suites of Common/tests (ported to common/).

================================================================================
| Test Module File                                               |  Test Cases |
--------------------------------------------------------------------------------
| tests/nettests/                                                |             |
| ├── async_linq/                                                |             |
| │   ├── test_aggregate.py                                      |          11 |
| │   ├── test_all.py                                            |           7 |
| │   ├── test_any.py                                            |           8 |
| │   ├── test_append.py                                         |          20 |
| │   ├── test_average.py                                        |          10 |
| │   ├── test_cast.py                                           |           6 |
| │   ├── test_chunk.py                                          |           5 |
| │   ├── test_concat.py                                         |          24 |
| │   ├── test_contains.py                                       |          11 |
| │   ├── test_count.py                                          |           8 |
| │   ├── test_default_if_empty.py                               |           7 |
| │   ├── test_distinct.py                                       |          10 |
| │   ├── test_distinct_by.py                                    |          11 |
| │   ├── test_element_at.py                                     |           8 |
| │   ├── test_empty.py                                          |           2 |
| │   ├── test_except.py                                         |          12 |
| │   ├── test_except_by.py                                      |          13 |
| │   ├── test_first.py                                          |           8 |
| │   ├── test_first_or_default.py                               |           8 |
| │   ├── test_full_join.py                                      |          11 |
| │   ├── test_group_by.py                                       |           5 |
| │   ├── test_group_join.py                                     |           9 |
| │   ├── test_index.py                                          |           8 |
| │   ├── test_intersect.py                                      |          12 |
| │   ├── test_join.py                                           |           9 |
| │   ├── test_last.py                                           |           8 |
| │   ├── test_last_or_default.py                                |           8 |
| │   ├── test_left_join.py                                      |          10 |
| │   ├── test_max.py                                            |          11 |
| │   ├── test_max_by.py                                         |          13 |
| │   ├── test_min.py                                            |          11 |
| │   ├── test_min_by.py                                         |          13 |
| │   ├── test_of_type.py                                        |           5 |
| │   ├── test_order_by.py                                       |          18 |
| │   ├── test_prepend.py                                        |          19 |
| │   ├── test_range.py                                          |           3 |
| │   ├── test_repeat.py                                         |           3 |
| │   ├── test_reverse.py                                        |           8 |
| │   ├── test_select.py                                         |           9 |
| │   ├── test_select_many.py                                    |           5 |
| │   ├── test_single.py                                         |           9 |
| │   ├── test_single_or_default.py                              |           9 |
| │   ├── test_skip.py                                           |           9 |
| │   ├── test_skip_last.py                                      |           9 |
| │   ├── test_sum.py                                            |          10 |
| │   ├── test_take.py                                           |           9 |
| │   ├── test_take_last.py                                      |           9 |
| │   ├── test_to_async_enumerable.py                            |          10 |
| │   ├── test_to_dictionary.py                                  |           5 |
| │   ├── test_to_list.py                                        |           9 |
| │   ├── test_to_lookup.py                                      |           4 |
| │   ├── test_union.py                                          |          12 |
| │   ├── test_where.py                                          |           9 |
| │   └── test_zip.py                                            |          12 |
| ├── channels/                                                  |             |
| │   ├── test_bounded_channel.py                                |         139 |
| │   ├── test_channel.py                                        |          16 |
| │   ├── test_channel_closed_exception.py                       |           2 |
| │   ├── test_debug_attribute.py                                |           0 |
| │   ├── test_priority_unbounded_channel.py                     |          85 |
| │   ├── test_rendezvous_channel.py                             |         104 |
| │   └── test_unbounded_channel.py                              |         338 |
| ├── concurrent/                                                |             |
| │   ├── test_concurrent_bag.py                                 |         130 |
| │   ├── test_concurrent_dictionary.py                          |          56 |
| │   ├── test_concurrent_dictionary_generic.py                  |        1236 |
| │   ├── test_concurrent_queue.py                               |         130 |
| │   ├── test_concurrent_stack.py                               |         124 |
| │   └── test_etw.py                                            |           0 |
| ├── linq/                                                      |             |
| │   ├── test_aggregate.py                                      |          42 |
| │   ├── test_all.py                                            |          80 |
| │   ├── test_any.py                                            |          90 |
| │   ├── test_append_prepend.py                                 |          36 |
| │   ├── test_average.py                                        |         572 |
| │   ├── test_cast.py                                           |          45 |
| │   ├── test_chunk.py                                          |          22 |
| │   ├── test_concat.py                                         |          64 |
| │   ├── test_contains.py                                       |         108 |
| │   ├── test_count.py                                          |          37 |
| │   ├── test_default_if_empty.py                               |          37 |
| │   ├── test_distinct.py                                       |          87 |
| │   ├── test_element_at.py                                     |          43 |
| │   ├── test_except.py                                         |          68 |
| │   ├── test_first.py                                          |          29 |
| │   ├── test_first_or_default.py                               |          50 |
| │   ├── test_full_join.py                                      |          37 |
| │   ├── test_generic_list.py                                   |          95 |
| │   ├── test_group_by.py                                       |          23 |
| │   ├── test_group_join.py                                     |          53 |
| │   ├── test_index.py                                          |           6 |
| │   ├── test_intersect.py                                      |          42 |
| │   ├── test_join.py                                           |          47 |
| │   ├── test_last.py                                           |          29 |
| │   ├── test_last_or_default.py                                |          45 |
| │   ├── test_left_join.py                                      |          47 |
| │   ├── test_max.py                                            |        1100 |
| │   ├── test_min.py                                            |         968 |
| │   ├── test_of_type.py                                        |          38 |
| │   ├── test_order_by.py                                       |         100 |
| │   ├── test_order_descending_by.py                            |          45 |
| │   ├── test_reverse.py                                        |          35 |
| │   ├── test_select.py                                         |         140 |
| │   ├── test_select_many.py                                    |          85 |
| │   ├── test_single.py                                         |          34 |
| │   ├── test_single_or_default.py                              |          48 |
| │   ├── test_skip.py                                           |          75 |
| │   ├── test_skip_last.py                                      |        1221 |
| │   ├── test_sum.py                                            |         134 |
| │   ├── test_take.py                                           |          39 |
| │   ├── test_take_last.py                                      |        1221 |
| │   ├── test_then_by.py                                        |          40 |
| │   ├── test_then_descending_by.py                             |          34 |
| │   ├── test_to_dictionary.py                                  |          32 |
| │   ├── test_to_list.py                                        |          40 |
| │   ├── test_to_lookup.py                                      |          26 |
| │   ├── test_union.py                                          |          62 |
| │   ├── test_where.py                                          |          76 |
| │   └── test_zip.py                                            |         101 |
| ├── task/                                                      |             |
| │   ├── test_cancellation.py                                   |          69 |
| │   ├── test_task_completion_source.py                         |          26 |
| │   ├── test_task_continue_with.py                             |          15 |
| │   ├── test_task_continue_with_func_and_action.py             |          16 |
| │   ├── test_task_continue_with_func_and_action_args.py        |          20 |
| │   ├── test_task_factory.py                                   |           3 |
| │   ├── test_task_rt.py                                        |          13 |
| │   ├── test_task_rt_core.py                                   |          27 |
| │   └── test_task_wait_all_any.py                              |          62 |
| └── threading/                                                 |             |
|     ├── test_semaphore_slim.py                                 |          39 |
|     ├── test_semaphore_slim_cancellation.py                    |           4 |
|     └── test_thread_local.py                                   |          15 |
--------------------------------------------------------------------------------
| GRAND TOTALS                                                   |       10709 |
================================================================================

Metadata

Release files for flpit 0.4.0

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

Source distribution (sdist)

Source distribution for flpit 0.4.0
File Size Uploaded Provenance Actions
flpit-0.4.0.tar.gz 118.8 kB Without provenance Details for flpit-0.4.0.tar.gz

Built distribution (wheel)

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

Total release size: 247.1 kB

Release files / flpit-0.4.0.tar.gz

Download URL flpit-0.4.0.tar.gz
Size 118.8 kB
Tags Source
SHA-256 checksum
How to use checksums
cec152a8adf3e1ec55e1efd8ecbb985d4a2ce3ef9fd34bce5df6dcc6a1e4427b
BLAKE2b-256 checksum
How to use checksums
8d583c73a8a150f31340f3b34aea014c83d7fcfdbd522554ece1fa14263217c8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / flpit-0.4.0-py3-none-any.whl

Download URL flpit-0.4.0-py3-none-any.whl
Size 128.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f192be96a9f53f1104423571562b7a39b5e0a8778cb158411486934fa06bd25c
BLAKE2b-256 checksum
How to use checksums
910582b45ee851e1a76f39c54ab976299454f71de67f8e60b44dfc1cae819feb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for flpit 0.4.0

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

0.4.0 This release

2 release files 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