flpit 0.3.4__tar.gz → 0.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {flpit-0.3.4 → flpit-0.4.0}/.gitignore +3 -1
- flpit-0.4.0/PKG-INFO +261 -0
- flpit-0.4.0/README.md +233 -0
- {flpit-0.3.4 → flpit-0.4.0}/pyproject.toml +20 -3
- {flpit-0.3.4 → flpit-0.4.0}/src/flpit/__init__.py +9 -0
- flpit-0.4.0/src/flpit/channels.py +1224 -0
- flpit-0.4.0/src/flpit/concurrent.py +856 -0
- flpit-0.4.0/src/flpit/core/async_linq.py +1942 -0
- flpit-0.4.0/src/flpit/core/comparers.py +97 -0
- {flpit-0.3.4 → flpit-0.4.0}/src/flpit/core/linq.py +65 -2
- flpit-0.4.0/src/flpit/csv.py +644 -0
- {flpit-0.3.4 → flpit-0.4.0}/src/flpit/flp.py +13 -1
- flpit-0.4.0/src/flpit/json/__init__.py +168 -0
- flpit-0.4.0/src/flpit/json/_core.py +419 -0
- flpit-0.3.4/src/flpit/json.py → flpit-0.4.0/src/flpit/json/_msgspec.py +164 -245
- flpit-0.4.0/src/flpit/json/_native.py +1076 -0
- flpit-0.4.0/src/flpit/task.py +3629 -0
- flpit-0.4.0/src/flpit/threading.py +883 -0
- flpit-0.3.4/PKG-INFO +0 -579
- flpit-0.3.4/README.md +0 -555
- flpit-0.3.4/src/flpit/csv.py +0 -188
- flpit-0.3.4/src/flpit/task.py +0 -2235
- flpit-0.3.4/src/flpit/threading.py +0 -171
- {flpit-0.3.4 → flpit-0.4.0}/LICENSE +0 -0
- {flpit-0.3.4 → flpit-0.4.0}/src/flp/__init__.py +0 -0
- {flpit-0.3.4 → flpit-0.4.0}/src/flpit/core/__init__.py +0 -0
- {flpit-0.3.4 → flpit-0.4.0}/src/flpit/core/_grouping.py +0 -0
- {flpit-0.3.4 → flpit-0.4.0}/src/flpit/core/_index.py +0 -0
- {flpit-0.3.4 → flpit-0.4.0}/src/flpit/core/_join.py +0 -0
- {flpit-0.3.4 → flpit-0.4.0}/src/flpit/core/_lookup.py +0 -0
- {flpit-0.3.4 → flpit-0.4.0}/src/flpit/core/_zip.py +0 -0
- {flpit-0.3.4 → flpit-0.4.0}/src/flpit/py.typed +0 -0
flpit-0.4.0/PKG-INFO
ADDED
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: flpit
|
|
3
|
+
Version: 0.4.0
|
|
4
|
+
Summary: Fluent LINQ for Python — flip your iterables
|
|
5
|
+
Project-URL: Homepage, https://github.com/riemar/flpit
|
|
6
|
+
Project-URL: Repository, https://github.com/riemar/flpit
|
|
7
|
+
Project-URL: Issues, https://github.com/riemar/flpit/issues
|
|
8
|
+
License: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Keywords: fluent,generators,iterable,lazy-evaluation,linq,pipeline,pyrefly,type-safe
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
19
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
20
|
+
Classifier: Typing :: Typed
|
|
21
|
+
Requires-Python: >=3.12
|
|
22
|
+
Requires-Dist: msgspec>=0.22.0; platform_python_implementation == 'CPython' and sys_platform != 'emscripten'
|
|
23
|
+
Provides-Extra: msgspec
|
|
24
|
+
Requires-Dist: msgspec>=0.22.0; extra == 'msgspec'
|
|
25
|
+
Provides-Extra: whenever
|
|
26
|
+
Requires-Dist: whenever>=0.11; extra == 'whenever'
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
|
|
29
|
+
# FlpIt
|
|
30
|
+
|
|
31
|
+
**[📖 Documentation](https://riemar.github.io/flpit/)** | **[🌐 GitHub](https://github.com/riemar/flpit)** | **[📦 PyPI](https://pypi.org/project/flpit/)**
|
|
32
|
+
|
|
33
|
+
> **Fluent LINQ for Python — LINQ semantics, Python-native execution**
|
|
34
|
+
|
|
35
|
+
`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.
|
|
36
|
+
|
|
37
|
+
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.
|
|
38
|
+
|
|
39
|
+
> **Semantic goal:** `flp` strives to faithfully reproduce .NET LINQ semantics.
|
|
40
|
+
> Where Python's language or type system requires a different API contract, the contract is adapted accordingly,
|
|
41
|
+
> and [each deviation is documented](https://riemar.github.io/flpit/semantics/differences/).
|
|
42
|
+
> The implementation is actively developed, and further deviations may still exist.
|
|
43
|
+
|
|
44
|
+
## 💡 Quick Start
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
uv add flpit # or: pip install flpit
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
```python
|
|
51
|
+
from flpit import flp, FlpIt, FlpList
|
|
52
|
+
|
|
53
|
+
# A lazy, streaming pipeline: nothing has run yet.
|
|
54
|
+
query: FlpIt[int] = (
|
|
55
|
+
flp.it(range(1, 11))
|
|
56
|
+
.where(lambda x: x % 2 == 0)
|
|
57
|
+
.select(lambda x: x * 10)
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
# Explicit materialization.
|
|
61
|
+
result: FlpList[int] = query.to_list()
|
|
62
|
+
# [20, 40, 60, 80, 100]
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## 🤸 Flipping the Pipeline
|
|
66
|
+
|
|
67
|
+
Native Python functional operations read inside-out. A FlpIt pipeline reads in the order things happen:
|
|
68
|
+
|
|
69
|
+
```python
|
|
70
|
+
# 🔁 Native built-ins
|
|
71
|
+
result = list(map(lambda x: x * 10, filter(lambda x: x % 2 == 0, range(1, 11))))
|
|
72
|
+
|
|
73
|
+
# 🤸 FlpIt pipeline
|
|
74
|
+
result = (
|
|
75
|
+
flp.it(range(1, 11))
|
|
76
|
+
.where(lambda x: x % 2 == 0)
|
|
77
|
+
.select(lambda x: x * 10)
|
|
78
|
+
.to_list()
|
|
79
|
+
)
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## ⚡ What's in the Box
|
|
83
|
+
|
|
84
|
+
* **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](https://riemar.github.io/flpit/guide/getting-started/)
|
|
85
|
+
* **Async queries (`AsyncFlpIt`)**: the `IAsyncEnumerable<T>` counterpart, with async callbacks, cancellation and cleanup. [Docs](https://riemar.github.io/flpit/async/)
|
|
86
|
+
* **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](https://riemar.github.io/flpit/semantics/)
|
|
87
|
+
* **Typed JSON and CSV**: dataclasses to and from JSON and CSV, with `msgspec` or a pure-Python backend. [JSON](https://riemar.github.io/flpit/guide/json/), [CSV](https://riemar.github.io/flpit/guide/csv/)
|
|
88
|
+
* **Task runtime**: an `asyncio`-free runtime modelled on the .NET thread pool, with `Task.when_all`, continuations and cooperative cancellation. [Docs](https://riemar.github.io/flpit/task/)
|
|
89
|
+
* **Channels, concurrent collections and threading primitives**: `Channel[T]`, `ConcurrentDictionary`, `SemaphoreSlim` and friends. [Docs](https://riemar.github.io/flpit/concurrency/channels/)
|
|
90
|
+
* **Static-first typing**: designed for precise `pyrefly` inference without plugins (mypy and pyright may give varying results).
|
|
91
|
+
|
|
92
|
+
FlpIt models in-memory LINQ (`IEnumerable`). It does not model `IQueryable` or expression trees.
|
|
93
|
+
|
|
94
|
+
## ⚙️ Installation
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
uv add flpit
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
msgspec is installed automatically on CPython. On other interpreters (PyPy, Pyodide) flpit
|
|
101
|
+
installs without it and uses the native JSON backend. Free-threaded CPython 3.13t is not
|
|
102
|
+
supported by msgspec: install there with `--no-deps`, or use 3.14t.
|
|
103
|
+
|
|
104
|
+
## 🧭 Like FlpIt? Give .NET a try.
|
|
105
|
+
|
|
106
|
+
Enjoying FlpIt's .NET-inspired programming model? [Here's where it comes from](https://riemar.github.io/flpit/dotnet/): try C# in your browser, explore LINQ, or keep your Python and call it from .NET.
|
|
107
|
+
|
|
108
|
+
## 📜 License
|
|
109
|
+
|
|
110
|
+
Distributed under the MIT License. See `LICENSE` for more information.
|
|
111
|
+
|
|
112
|
+
## Migrated .NET Unit Tests
|
|
113
|
+
|
|
114
|
+
> Migrated from the official .NET Runtime LINQ Tests.
|
|
115
|
+
> 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.
|
|
116
|
+
> `async_linq/` is migrated from the .NET 10 `System.Linq.AsyncEnumerable` tests and exercises `AsyncFlpIt` on the flpit task runtime.
|
|
117
|
+
> `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/`).
|
|
118
|
+
|
|
119
|
+
```
|
|
120
|
+
================================================================================
|
|
121
|
+
| Test Module File | Test Cases |
|
|
122
|
+
--------------------------------------------------------------------------------
|
|
123
|
+
| tests/nettests/ | |
|
|
124
|
+
| ├── async_linq/ | |
|
|
125
|
+
| │ ├── test_aggregate.py | 11 |
|
|
126
|
+
| │ ├── test_all.py | 7 |
|
|
127
|
+
| │ ├── test_any.py | 8 |
|
|
128
|
+
| │ ├── test_append.py | 20 |
|
|
129
|
+
| │ ├── test_average.py | 10 |
|
|
130
|
+
| │ ├── test_cast.py | 6 |
|
|
131
|
+
| │ ├── test_chunk.py | 5 |
|
|
132
|
+
| │ ├── test_concat.py | 24 |
|
|
133
|
+
| │ ├── test_contains.py | 11 |
|
|
134
|
+
| │ ├── test_count.py | 8 |
|
|
135
|
+
| │ ├── test_default_if_empty.py | 7 |
|
|
136
|
+
| │ ├── test_distinct.py | 10 |
|
|
137
|
+
| │ ├── test_distinct_by.py | 11 |
|
|
138
|
+
| │ ├── test_element_at.py | 8 |
|
|
139
|
+
| │ ├── test_empty.py | 2 |
|
|
140
|
+
| │ ├── test_except.py | 12 |
|
|
141
|
+
| │ ├── test_except_by.py | 13 |
|
|
142
|
+
| │ ├── test_first.py | 8 |
|
|
143
|
+
| │ ├── test_first_or_default.py | 8 |
|
|
144
|
+
| │ ├── test_full_join.py | 11 |
|
|
145
|
+
| │ ├── test_group_by.py | 5 |
|
|
146
|
+
| │ ├── test_group_join.py | 9 |
|
|
147
|
+
| │ ├── test_index.py | 8 |
|
|
148
|
+
| │ ├── test_intersect.py | 12 |
|
|
149
|
+
| │ ├── test_join.py | 9 |
|
|
150
|
+
| │ ├── test_last.py | 8 |
|
|
151
|
+
| │ ├── test_last_or_default.py | 8 |
|
|
152
|
+
| │ ├── test_left_join.py | 10 |
|
|
153
|
+
| │ ├── test_max.py | 11 |
|
|
154
|
+
| │ ├── test_max_by.py | 13 |
|
|
155
|
+
| │ ├── test_min.py | 11 |
|
|
156
|
+
| │ ├── test_min_by.py | 13 |
|
|
157
|
+
| │ ├── test_of_type.py | 5 |
|
|
158
|
+
| │ ├── test_order_by.py | 18 |
|
|
159
|
+
| │ ├── test_prepend.py | 19 |
|
|
160
|
+
| │ ├── test_range.py | 3 |
|
|
161
|
+
| │ ├── test_repeat.py | 3 |
|
|
162
|
+
| │ ├── test_reverse.py | 8 |
|
|
163
|
+
| │ ├── test_select.py | 9 |
|
|
164
|
+
| │ ├── test_select_many.py | 5 |
|
|
165
|
+
| │ ├── test_single.py | 9 |
|
|
166
|
+
| │ ├── test_single_or_default.py | 9 |
|
|
167
|
+
| │ ├── test_skip.py | 9 |
|
|
168
|
+
| │ ├── test_skip_last.py | 9 |
|
|
169
|
+
| │ ├── test_sum.py | 10 |
|
|
170
|
+
| │ ├── test_take.py | 9 |
|
|
171
|
+
| │ ├── test_take_last.py | 9 |
|
|
172
|
+
| │ ├── test_to_async_enumerable.py | 10 |
|
|
173
|
+
| │ ├── test_to_dictionary.py | 5 |
|
|
174
|
+
| │ ├── test_to_list.py | 9 |
|
|
175
|
+
| │ ├── test_to_lookup.py | 4 |
|
|
176
|
+
| │ ├── test_union.py | 12 |
|
|
177
|
+
| │ ├── test_where.py | 9 |
|
|
178
|
+
| │ └── test_zip.py | 12 |
|
|
179
|
+
| ├── channels/ | |
|
|
180
|
+
| │ ├── test_bounded_channel.py | 139 |
|
|
181
|
+
| │ ├── test_channel.py | 16 |
|
|
182
|
+
| │ ├── test_channel_closed_exception.py | 2 |
|
|
183
|
+
| │ ├── test_debug_attribute.py | 0 |
|
|
184
|
+
| │ ├── test_priority_unbounded_channel.py | 85 |
|
|
185
|
+
| │ ├── test_rendezvous_channel.py | 104 |
|
|
186
|
+
| │ └── test_unbounded_channel.py | 338 |
|
|
187
|
+
| ├── concurrent/ | |
|
|
188
|
+
| │ ├── test_concurrent_bag.py | 130 |
|
|
189
|
+
| │ ├── test_concurrent_dictionary.py | 56 |
|
|
190
|
+
| │ ├── test_concurrent_dictionary_generic.py | 1236 |
|
|
191
|
+
| │ ├── test_concurrent_queue.py | 130 |
|
|
192
|
+
| │ ├── test_concurrent_stack.py | 124 |
|
|
193
|
+
| │ └── test_etw.py | 0 |
|
|
194
|
+
| ├── linq/ | |
|
|
195
|
+
| │ ├── test_aggregate.py | 42 |
|
|
196
|
+
| │ ├── test_all.py | 80 |
|
|
197
|
+
| │ ├── test_any.py | 90 |
|
|
198
|
+
| │ ├── test_append_prepend.py | 36 |
|
|
199
|
+
| │ ├── test_average.py | 572 |
|
|
200
|
+
| │ ├── test_cast.py | 45 |
|
|
201
|
+
| │ ├── test_chunk.py | 22 |
|
|
202
|
+
| │ ├── test_concat.py | 64 |
|
|
203
|
+
| │ ├── test_contains.py | 108 |
|
|
204
|
+
| │ ├── test_count.py | 37 |
|
|
205
|
+
| │ ├── test_default_if_empty.py | 37 |
|
|
206
|
+
| │ ├── test_distinct.py | 87 |
|
|
207
|
+
| │ ├── test_element_at.py | 43 |
|
|
208
|
+
| │ ├── test_except.py | 68 |
|
|
209
|
+
| │ ├── test_first.py | 29 |
|
|
210
|
+
| │ ├── test_first_or_default.py | 50 |
|
|
211
|
+
| │ ├── test_full_join.py | 37 |
|
|
212
|
+
| │ ├── test_generic_list.py | 95 |
|
|
213
|
+
| │ ├── test_group_by.py | 23 |
|
|
214
|
+
| │ ├── test_group_join.py | 53 |
|
|
215
|
+
| │ ├── test_index.py | 6 |
|
|
216
|
+
| │ ├── test_intersect.py | 42 |
|
|
217
|
+
| │ ├── test_join.py | 47 |
|
|
218
|
+
| │ ├── test_last.py | 29 |
|
|
219
|
+
| │ ├── test_last_or_default.py | 45 |
|
|
220
|
+
| │ ├── test_left_join.py | 47 |
|
|
221
|
+
| │ ├── test_max.py | 1100 |
|
|
222
|
+
| │ ├── test_min.py | 968 |
|
|
223
|
+
| │ ├── test_of_type.py | 38 |
|
|
224
|
+
| │ ├── test_order_by.py | 100 |
|
|
225
|
+
| │ ├── test_order_descending_by.py | 45 |
|
|
226
|
+
| │ ├── test_reverse.py | 35 |
|
|
227
|
+
| │ ├── test_select.py | 140 |
|
|
228
|
+
| │ ├── test_select_many.py | 85 |
|
|
229
|
+
| │ ├── test_single.py | 34 |
|
|
230
|
+
| │ ├── test_single_or_default.py | 48 |
|
|
231
|
+
| │ ├── test_skip.py | 75 |
|
|
232
|
+
| │ ├── test_skip_last.py | 1221 |
|
|
233
|
+
| │ ├── test_sum.py | 134 |
|
|
234
|
+
| │ ├── test_take.py | 39 |
|
|
235
|
+
| │ ├── test_take_last.py | 1221 |
|
|
236
|
+
| │ ├── test_then_by.py | 40 |
|
|
237
|
+
| │ ├── test_then_descending_by.py | 34 |
|
|
238
|
+
| │ ├── test_to_dictionary.py | 32 |
|
|
239
|
+
| │ ├── test_to_list.py | 40 |
|
|
240
|
+
| │ ├── test_to_lookup.py | 26 |
|
|
241
|
+
| │ ├── test_union.py | 62 |
|
|
242
|
+
| │ ├── test_where.py | 76 |
|
|
243
|
+
| │ └── test_zip.py | 101 |
|
|
244
|
+
| ├── task/ | |
|
|
245
|
+
| │ ├── test_cancellation.py | 69 |
|
|
246
|
+
| │ ├── test_task_completion_source.py | 26 |
|
|
247
|
+
| │ ├── test_task_continue_with.py | 15 |
|
|
248
|
+
| │ ├── test_task_continue_with_func_and_action.py | 16 |
|
|
249
|
+
| │ ├── test_task_continue_with_func_and_action_args.py | 20 |
|
|
250
|
+
| │ ├── test_task_factory.py | 3 |
|
|
251
|
+
| │ ├── test_task_rt.py | 13 |
|
|
252
|
+
| │ ├── test_task_rt_core.py | 27 |
|
|
253
|
+
| │ └── test_task_wait_all_any.py | 62 |
|
|
254
|
+
| └── threading/ | |
|
|
255
|
+
| ├── test_semaphore_slim.py | 39 |
|
|
256
|
+
| ├── test_semaphore_slim_cancellation.py | 4 |
|
|
257
|
+
| └── test_thread_local.py | 15 |
|
|
258
|
+
--------------------------------------------------------------------------------
|
|
259
|
+
| GRAND TOTALS | 10709 |
|
|
260
|
+
================================================================================
|
|
261
|
+
```
|
flpit-0.4.0/README.md
ADDED
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
# FlpIt
|
|
2
|
+
|
|
3
|
+
**[📖 Documentation](https://riemar.github.io/flpit/)** | **[🌐 GitHub](https://github.com/riemar/flpit)** | **[📦 PyPI](https://pypi.org/project/flpit/)**
|
|
4
|
+
|
|
5
|
+
> **Fluent LINQ for Python — LINQ semantics, Python-native execution**
|
|
6
|
+
|
|
7
|
+
`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.
|
|
8
|
+
|
|
9
|
+
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.
|
|
10
|
+
|
|
11
|
+
> **Semantic goal:** `flp` strives to faithfully reproduce .NET LINQ semantics.
|
|
12
|
+
> Where Python's language or type system requires a different API contract, the contract is adapted accordingly,
|
|
13
|
+
> and [each deviation is documented](https://riemar.github.io/flpit/semantics/differences/).
|
|
14
|
+
> The implementation is actively developed, and further deviations may still exist.
|
|
15
|
+
|
|
16
|
+
## 💡 Quick Start
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
uv add flpit # or: pip install flpit
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
```python
|
|
23
|
+
from flpit import flp, FlpIt, FlpList
|
|
24
|
+
|
|
25
|
+
# A lazy, streaming pipeline: nothing has run yet.
|
|
26
|
+
query: FlpIt[int] = (
|
|
27
|
+
flp.it(range(1, 11))
|
|
28
|
+
.where(lambda x: x % 2 == 0)
|
|
29
|
+
.select(lambda x: x * 10)
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
# Explicit materialization.
|
|
33
|
+
result: FlpList[int] = query.to_list()
|
|
34
|
+
# [20, 40, 60, 80, 100]
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## 🤸 Flipping the Pipeline
|
|
38
|
+
|
|
39
|
+
Native Python functional operations read inside-out. A FlpIt pipeline reads in the order things happen:
|
|
40
|
+
|
|
41
|
+
```python
|
|
42
|
+
# 🔁 Native built-ins
|
|
43
|
+
result = list(map(lambda x: x * 10, filter(lambda x: x % 2 == 0, range(1, 11))))
|
|
44
|
+
|
|
45
|
+
# 🤸 FlpIt pipeline
|
|
46
|
+
result = (
|
|
47
|
+
flp.it(range(1, 11))
|
|
48
|
+
.where(lambda x: x % 2 == 0)
|
|
49
|
+
.select(lambda x: x * 10)
|
|
50
|
+
.to_list()
|
|
51
|
+
)
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## ⚡ What's in the Box
|
|
55
|
+
|
|
56
|
+
* **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](https://riemar.github.io/flpit/guide/getting-started/)
|
|
57
|
+
* **Async queries (`AsyncFlpIt`)**: the `IAsyncEnumerable<T>` counterpart, with async callbacks, cancellation and cleanup. [Docs](https://riemar.github.io/flpit/async/)
|
|
58
|
+
* **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](https://riemar.github.io/flpit/semantics/)
|
|
59
|
+
* **Typed JSON and CSV**: dataclasses to and from JSON and CSV, with `msgspec` or a pure-Python backend. [JSON](https://riemar.github.io/flpit/guide/json/), [CSV](https://riemar.github.io/flpit/guide/csv/)
|
|
60
|
+
* **Task runtime**: an `asyncio`-free runtime modelled on the .NET thread pool, with `Task.when_all`, continuations and cooperative cancellation. [Docs](https://riemar.github.io/flpit/task/)
|
|
61
|
+
* **Channels, concurrent collections and threading primitives**: `Channel[T]`, `ConcurrentDictionary`, `SemaphoreSlim` and friends. [Docs](https://riemar.github.io/flpit/concurrency/channels/)
|
|
62
|
+
* **Static-first typing**: designed for precise `pyrefly` inference without plugins (mypy and pyright may give varying results).
|
|
63
|
+
|
|
64
|
+
FlpIt models in-memory LINQ (`IEnumerable`). It does not model `IQueryable` or expression trees.
|
|
65
|
+
|
|
66
|
+
## ⚙️ Installation
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
uv add flpit
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
msgspec is installed automatically on CPython. On other interpreters (PyPy, Pyodide) flpit
|
|
73
|
+
installs without it and uses the native JSON backend. Free-threaded CPython 3.13t is not
|
|
74
|
+
supported by msgspec: install there with `--no-deps`, or use 3.14t.
|
|
75
|
+
|
|
76
|
+
## 🧭 Like FlpIt? Give .NET a try.
|
|
77
|
+
|
|
78
|
+
Enjoying FlpIt's .NET-inspired programming model? [Here's where it comes from](https://riemar.github.io/flpit/dotnet/): try C# in your browser, explore LINQ, or keep your Python and call it from .NET.
|
|
79
|
+
|
|
80
|
+
## 📜 License
|
|
81
|
+
|
|
82
|
+
Distributed under the MIT License. See `LICENSE` for more information.
|
|
83
|
+
|
|
84
|
+
## Migrated .NET Unit Tests
|
|
85
|
+
|
|
86
|
+
> Migrated from the official .NET Runtime LINQ Tests.
|
|
87
|
+
> 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.
|
|
88
|
+
> `async_linq/` is migrated from the .NET 10 `System.Linq.AsyncEnumerable` tests and exercises `AsyncFlpIt` on the flpit task runtime.
|
|
89
|
+
> `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/`).
|
|
90
|
+
|
|
91
|
+
```
|
|
92
|
+
================================================================================
|
|
93
|
+
| Test Module File | Test Cases |
|
|
94
|
+
--------------------------------------------------------------------------------
|
|
95
|
+
| tests/nettests/ | |
|
|
96
|
+
| ├── async_linq/ | |
|
|
97
|
+
| │ ├── test_aggregate.py | 11 |
|
|
98
|
+
| │ ├── test_all.py | 7 |
|
|
99
|
+
| │ ├── test_any.py | 8 |
|
|
100
|
+
| │ ├── test_append.py | 20 |
|
|
101
|
+
| │ ├── test_average.py | 10 |
|
|
102
|
+
| │ ├── test_cast.py | 6 |
|
|
103
|
+
| │ ├── test_chunk.py | 5 |
|
|
104
|
+
| │ ├── test_concat.py | 24 |
|
|
105
|
+
| │ ├── test_contains.py | 11 |
|
|
106
|
+
| │ ├── test_count.py | 8 |
|
|
107
|
+
| │ ├── test_default_if_empty.py | 7 |
|
|
108
|
+
| │ ├── test_distinct.py | 10 |
|
|
109
|
+
| │ ├── test_distinct_by.py | 11 |
|
|
110
|
+
| │ ├── test_element_at.py | 8 |
|
|
111
|
+
| │ ├── test_empty.py | 2 |
|
|
112
|
+
| │ ├── test_except.py | 12 |
|
|
113
|
+
| │ ├── test_except_by.py | 13 |
|
|
114
|
+
| │ ├── test_first.py | 8 |
|
|
115
|
+
| │ ├── test_first_or_default.py | 8 |
|
|
116
|
+
| │ ├── test_full_join.py | 11 |
|
|
117
|
+
| │ ├── test_group_by.py | 5 |
|
|
118
|
+
| │ ├── test_group_join.py | 9 |
|
|
119
|
+
| │ ├── test_index.py | 8 |
|
|
120
|
+
| │ ├── test_intersect.py | 12 |
|
|
121
|
+
| │ ├── test_join.py | 9 |
|
|
122
|
+
| │ ├── test_last.py | 8 |
|
|
123
|
+
| │ ├── test_last_or_default.py | 8 |
|
|
124
|
+
| │ ├── test_left_join.py | 10 |
|
|
125
|
+
| │ ├── test_max.py | 11 |
|
|
126
|
+
| │ ├── test_max_by.py | 13 |
|
|
127
|
+
| │ ├── test_min.py | 11 |
|
|
128
|
+
| │ ├── test_min_by.py | 13 |
|
|
129
|
+
| │ ├── test_of_type.py | 5 |
|
|
130
|
+
| │ ├── test_order_by.py | 18 |
|
|
131
|
+
| │ ├── test_prepend.py | 19 |
|
|
132
|
+
| │ ├── test_range.py | 3 |
|
|
133
|
+
| │ ├── test_repeat.py | 3 |
|
|
134
|
+
| │ ├── test_reverse.py | 8 |
|
|
135
|
+
| │ ├── test_select.py | 9 |
|
|
136
|
+
| │ ├── test_select_many.py | 5 |
|
|
137
|
+
| │ ├── test_single.py | 9 |
|
|
138
|
+
| │ ├── test_single_or_default.py | 9 |
|
|
139
|
+
| │ ├── test_skip.py | 9 |
|
|
140
|
+
| │ ├── test_skip_last.py | 9 |
|
|
141
|
+
| │ ├── test_sum.py | 10 |
|
|
142
|
+
| │ ├── test_take.py | 9 |
|
|
143
|
+
| │ ├── test_take_last.py | 9 |
|
|
144
|
+
| │ ├── test_to_async_enumerable.py | 10 |
|
|
145
|
+
| │ ├── test_to_dictionary.py | 5 |
|
|
146
|
+
| │ ├── test_to_list.py | 9 |
|
|
147
|
+
| │ ├── test_to_lookup.py | 4 |
|
|
148
|
+
| │ ├── test_union.py | 12 |
|
|
149
|
+
| │ ├── test_where.py | 9 |
|
|
150
|
+
| │ └── test_zip.py | 12 |
|
|
151
|
+
| ├── channels/ | |
|
|
152
|
+
| │ ├── test_bounded_channel.py | 139 |
|
|
153
|
+
| │ ├── test_channel.py | 16 |
|
|
154
|
+
| │ ├── test_channel_closed_exception.py | 2 |
|
|
155
|
+
| │ ├── test_debug_attribute.py | 0 |
|
|
156
|
+
| │ ├── test_priority_unbounded_channel.py | 85 |
|
|
157
|
+
| │ ├── test_rendezvous_channel.py | 104 |
|
|
158
|
+
| │ └── test_unbounded_channel.py | 338 |
|
|
159
|
+
| ├── concurrent/ | |
|
|
160
|
+
| │ ├── test_concurrent_bag.py | 130 |
|
|
161
|
+
| │ ├── test_concurrent_dictionary.py | 56 |
|
|
162
|
+
| │ ├── test_concurrent_dictionary_generic.py | 1236 |
|
|
163
|
+
| │ ├── test_concurrent_queue.py | 130 |
|
|
164
|
+
| │ ├── test_concurrent_stack.py | 124 |
|
|
165
|
+
| │ └── test_etw.py | 0 |
|
|
166
|
+
| ├── linq/ | |
|
|
167
|
+
| │ ├── test_aggregate.py | 42 |
|
|
168
|
+
| │ ├── test_all.py | 80 |
|
|
169
|
+
| │ ├── test_any.py | 90 |
|
|
170
|
+
| │ ├── test_append_prepend.py | 36 |
|
|
171
|
+
| │ ├── test_average.py | 572 |
|
|
172
|
+
| │ ├── test_cast.py | 45 |
|
|
173
|
+
| │ ├── test_chunk.py | 22 |
|
|
174
|
+
| │ ├── test_concat.py | 64 |
|
|
175
|
+
| │ ├── test_contains.py | 108 |
|
|
176
|
+
| │ ├── test_count.py | 37 |
|
|
177
|
+
| │ ├── test_default_if_empty.py | 37 |
|
|
178
|
+
| │ ├── test_distinct.py | 87 |
|
|
179
|
+
| │ ├── test_element_at.py | 43 |
|
|
180
|
+
| │ ├── test_except.py | 68 |
|
|
181
|
+
| │ ├── test_first.py | 29 |
|
|
182
|
+
| │ ├── test_first_or_default.py | 50 |
|
|
183
|
+
| │ ├── test_full_join.py | 37 |
|
|
184
|
+
| │ ├── test_generic_list.py | 95 |
|
|
185
|
+
| │ ├── test_group_by.py | 23 |
|
|
186
|
+
| │ ├── test_group_join.py | 53 |
|
|
187
|
+
| │ ├── test_index.py | 6 |
|
|
188
|
+
| │ ├── test_intersect.py | 42 |
|
|
189
|
+
| │ ├── test_join.py | 47 |
|
|
190
|
+
| │ ├── test_last.py | 29 |
|
|
191
|
+
| │ ├── test_last_or_default.py | 45 |
|
|
192
|
+
| │ ├── test_left_join.py | 47 |
|
|
193
|
+
| │ ├── test_max.py | 1100 |
|
|
194
|
+
| │ ├── test_min.py | 968 |
|
|
195
|
+
| │ ├── test_of_type.py | 38 |
|
|
196
|
+
| │ ├── test_order_by.py | 100 |
|
|
197
|
+
| │ ├── test_order_descending_by.py | 45 |
|
|
198
|
+
| │ ├── test_reverse.py | 35 |
|
|
199
|
+
| │ ├── test_select.py | 140 |
|
|
200
|
+
| │ ├── test_select_many.py | 85 |
|
|
201
|
+
| │ ├── test_single.py | 34 |
|
|
202
|
+
| │ ├── test_single_or_default.py | 48 |
|
|
203
|
+
| │ ├── test_skip.py | 75 |
|
|
204
|
+
| │ ├── test_skip_last.py | 1221 |
|
|
205
|
+
| │ ├── test_sum.py | 134 |
|
|
206
|
+
| │ ├── test_take.py | 39 |
|
|
207
|
+
| │ ├── test_take_last.py | 1221 |
|
|
208
|
+
| │ ├── test_then_by.py | 40 |
|
|
209
|
+
| │ ├── test_then_descending_by.py | 34 |
|
|
210
|
+
| │ ├── test_to_dictionary.py | 32 |
|
|
211
|
+
| │ ├── test_to_list.py | 40 |
|
|
212
|
+
| │ ├── test_to_lookup.py | 26 |
|
|
213
|
+
| │ ├── test_union.py | 62 |
|
|
214
|
+
| │ ├── test_where.py | 76 |
|
|
215
|
+
| │ └── test_zip.py | 101 |
|
|
216
|
+
| ├── task/ | |
|
|
217
|
+
| │ ├── test_cancellation.py | 69 |
|
|
218
|
+
| │ ├── test_task_completion_source.py | 26 |
|
|
219
|
+
| │ ├── test_task_continue_with.py | 15 |
|
|
220
|
+
| │ ├── test_task_continue_with_func_and_action.py | 16 |
|
|
221
|
+
| │ ├── test_task_continue_with_func_and_action_args.py | 20 |
|
|
222
|
+
| │ ├── test_task_factory.py | 3 |
|
|
223
|
+
| │ ├── test_task_rt.py | 13 |
|
|
224
|
+
| │ ├── test_task_rt_core.py | 27 |
|
|
225
|
+
| │ └── test_task_wait_all_any.py | 62 |
|
|
226
|
+
| └── threading/ | |
|
|
227
|
+
| ├── test_semaphore_slim.py | 39 |
|
|
228
|
+
| ├── test_semaphore_slim_cancellation.py | 4 |
|
|
229
|
+
| └── test_thread_local.py | 15 |
|
|
230
|
+
--------------------------------------------------------------------------------
|
|
231
|
+
| GRAND TOTALS | 10709 |
|
|
232
|
+
================================================================================
|
|
233
|
+
```
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "flpit"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.4.0"
|
|
4
4
|
description = "Fluent LINQ for Python — flip your iterables"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
requires-python = ">=3.12"
|
|
@@ -19,9 +19,17 @@ classifiers = [
|
|
|
19
19
|
"Typing :: Typed"
|
|
20
20
|
]
|
|
21
21
|
dependencies = [
|
|
22
|
-
|
|
22
|
+
# Fast JSON/CSV backend. Optional at runtime: without it flpit.json uses its
|
|
23
|
+
# pure-Python backend (PyPy, Pyodide and platforms without msgspec wheels).
|
|
24
|
+
"msgspec>=0.22.0; platform_python_implementation == 'CPython' and sys_platform != 'emscripten'",
|
|
23
25
|
]
|
|
24
26
|
|
|
27
|
+
[project.optional-dependencies]
|
|
28
|
+
# Ensure the fast backend explicitly, e.g. `pip install flpit[msgspec]`.
|
|
29
|
+
msgspec = ["msgspec>=0.22.0"]
|
|
30
|
+
# Typed date/time values (whenever) are picked up automatically when installed.
|
|
31
|
+
whenever = ["whenever>=0.11"]
|
|
32
|
+
|
|
25
33
|
[project.urls]
|
|
26
34
|
Homepage = "https://github.com/riemar/flpit"
|
|
27
35
|
Repository = "https://github.com/riemar/flpit"
|
|
@@ -36,6 +44,12 @@ dev = [
|
|
|
36
44
|
"pytest-benchmark>=5.3.0",
|
|
37
45
|
"mypy>=2.4.0",
|
|
38
46
|
"httpx>=0.28.1",
|
|
47
|
+
"whenever>=0.11.0",
|
|
48
|
+
]
|
|
49
|
+
docs = [
|
|
50
|
+
"mkdocs>=1.6,<2",
|
|
51
|
+
"mkdocs-material>=9.6,<10",
|
|
52
|
+
"mkdocstrings[python]>=0.30",
|
|
39
53
|
]
|
|
40
54
|
|
|
41
55
|
|
|
@@ -63,8 +77,11 @@ pythonpath = [
|
|
|
63
77
|
"src",
|
|
64
78
|
"tests"
|
|
65
79
|
]
|
|
66
|
-
|
|
80
|
+
|
|
81
|
+
addopts = "-m 'not benchmark and not stress and not task_examples'"
|
|
67
82
|
markers = [
|
|
68
83
|
"benchmark: performance benchmarks",
|
|
84
|
+
"stress: multi-core stress tests, run manually on a many-core machine",
|
|
85
|
+
"task_examples: slow Task runtime examples (run with: pytest -m task_examples)",
|
|
69
86
|
]
|
|
70
87
|
|
|
@@ -24,6 +24,8 @@ from flpit.core.linq import (
|
|
|
24
24
|
NoMatchError,
|
|
25
25
|
MultipleElementsError,
|
|
26
26
|
MultipleMatchesError,
|
|
27
|
+
NotSupportedError,
|
|
28
|
+
KeyNotFoundError,
|
|
27
29
|
|
|
28
30
|
#====================
|
|
29
31
|
# ArgumentExceptions
|
|
@@ -48,6 +50,7 @@ from flpit.core.linq import (
|
|
|
48
50
|
|
|
49
51
|
from flpit.core._grouping import Grouping
|
|
50
52
|
from flpit.core._lookup import Lookup
|
|
53
|
+
from flpit.core.async_linq import AsyncEnumerator, AsyncFlpIt, OrderedAsyncIt, async_flpit
|
|
51
54
|
|
|
52
55
|
__all__ = [
|
|
53
56
|
"flp",
|
|
@@ -56,12 +59,18 @@ __all__ = [
|
|
|
56
59
|
"Grouping",
|
|
57
60
|
"Lookup",
|
|
58
61
|
"OrderedIt",
|
|
62
|
+
"AsyncEnumerator",
|
|
63
|
+
"AsyncFlpIt",
|
|
64
|
+
"OrderedAsyncIt",
|
|
65
|
+
"async_flpit",
|
|
59
66
|
|
|
60
67
|
"InvalidOperationError",
|
|
61
68
|
"EmptySequenceError",
|
|
62
69
|
"NoMatchError",
|
|
63
70
|
"MultipleElementsError",
|
|
64
71
|
"MultipleMatchesError",
|
|
72
|
+
"NotSupportedError",
|
|
73
|
+
"KeyNotFoundError",
|
|
65
74
|
|
|
66
75
|
"ArgumentError",
|
|
67
76
|
"ArgumentNullError",
|