stdlibx-itertools 0.1.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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Lucino772
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,25 @@
1
+ Metadata-Version: 2.4
2
+ Name: stdlibx-itertools
3
+ Version: 0.1.0
4
+ Summary: stdlibx-itertools
5
+ Author: Lucino772
6
+ License-Expression: MIT
7
+ License-File: LICENSE
8
+ Requires-Dist: typing-extensions>=4.10.0,<5
9
+ Requires-Python: >=3.9
10
+ Project-URL: Documentation, http://stdlibx.lucapalmi.com/
11
+ Project-URL: Repository, https://github.com/Lucino772/stdlibx
12
+ Description-Content-Type: text/markdown
13
+
14
+ [![docs](https://github.com/Lucino772/stdlibx/actions/workflows/deploy-docs.yaml/badge.svg?branch=main)](https://github.com/Lucino772/stdlibx/actions/workflows/deploy-docs.yaml)
15
+
16
+ # stdlibx
17
+ **stdlibx** is a collection of small, focused Python utilities that simplify common programming patterns and help you write clearer, more composable code.
18
+
19
+ It provides practical tools for handling optional values, explicit error management, cancellation, composition, configuration, pattern matching, and reactive flows.
20
+
21
+ ## Documentation
22
+ Checkout the [documentation](http://stdlibx.lucapalmi.com/)
23
+
24
+ ## Licence
25
+ This project uses a **MIT** Licence [view](https://github.com/Lucino772/stdlibx/blob/main/LICENSE)
@@ -0,0 +1,12 @@
1
+ [![docs](https://github.com/Lucino772/stdlibx/actions/workflows/deploy-docs.yaml/badge.svg?branch=main)](https://github.com/Lucino772/stdlibx/actions/workflows/deploy-docs.yaml)
2
+
3
+ # stdlibx
4
+ **stdlibx** is a collection of small, focused Python utilities that simplify common programming patterns and help you write clearer, more composable code.
5
+
6
+ It provides practical tools for handling optional values, explicit error management, cancellation, composition, configuration, pattern matching, and reactive flows.
7
+
8
+ ## Documentation
9
+ Checkout the [documentation](http://stdlibx.lucapalmi.com/)
10
+
11
+ ## Licence
12
+ This project uses a **MIT** Licence [view](https://github.com/Lucino772/stdlibx/blob/main/LICENSE)
@@ -0,0 +1,25 @@
1
+ [project]
2
+ name = "stdlibx-itertools"
3
+ version = "0.1.0"
4
+ description = "stdlibx-itertools"
5
+ license = "MIT"
6
+ license-files = ["LICEN[CS]E*"]
7
+ readme = "README.md"
8
+ authors = [
9
+ { name = "Lucino772" }
10
+ ]
11
+ requires-python = ">=3.9"
12
+ dependencies = [
13
+ "typing_extensions>=4.10.0,<5"
14
+ ]
15
+
16
+ [project.urls]
17
+ Documentation = "http://stdlibx.lucapalmi.com/"
18
+ Repository = "https://github.com/Lucino772/stdlibx"
19
+
20
+ [tool.uv.build-backend]
21
+ module-name = "stdlibx.itertools"
22
+
23
+ [build-system]
24
+ requires = ["uv_build>=0.9.28,<0.10.0"]
25
+ build-backend = "uv_build"
@@ -0,0 +1,54 @@
1
+ from __future__ import annotations
2
+
3
+ import functools
4
+ from typing import TYPE_CHECKING, Callable, Iterable, TypeVar, Union
5
+
6
+ if TYPE_CHECKING:
7
+ from stdlibx.itertools._types import Operation
8
+
9
+ T = TypeVar("T")
10
+ U = TypeVar("U")
11
+
12
+
13
+ def map_(
14
+ func: Callable[[T], U], /, *, lazy: bool = True
15
+ ) -> Operation[Iterable[T], Iterable[U]]:
16
+ def _execute(iterable: Iterable[T]) -> Iterable[U]:
17
+ if lazy:
18
+ return map(func, iterable)
19
+ return [func(a) for a in iterable]
20
+
21
+ return _execute
22
+
23
+
24
+ def filter_(
25
+ func: Callable[[T], bool], /, *, lazy: bool = True
26
+ ) -> Operation[Iterable[T], Iterable[T]]:
27
+ def _execute(iterable: Iterable[T]) -> Iterable[T]:
28
+ if lazy:
29
+ return filter(func, iterable)
30
+ return [a for a in iterable if func(a)]
31
+
32
+ return _execute
33
+
34
+
35
+ def filter_none(
36
+ *, lazy: bool = True
37
+ ) -> Operation[Iterable[Union[T, None]], Iterable[T]]:
38
+ def _execute(iterable: Iterable[Union[T, None]]) -> Iterable[T]:
39
+ if lazy:
40
+ return (a for a in iterable if a is not None)
41
+ return [a for a in iterable if a is not None]
42
+
43
+ return _execute
44
+
45
+
46
+ def reduce(initial: T, func: Callable[[T, U], T]) -> Operation[Iterable[U], T]:
47
+ def _execute(iterable: Iterable[U]) -> T:
48
+ return functools.reduce(func, iterable, initial)
49
+
50
+ return _execute
51
+
52
+
53
+ def collect() -> Operation[Iterable[T], list[T]]:
54
+ return reduce([], lambda a, b: a + [b])
@@ -0,0 +1,10 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import Callable, TypeVar
4
+
5
+ from typing_extensions import TypeAlias
6
+
7
+ T = TypeVar("T")
8
+ U = TypeVar("U")
9
+
10
+ Operation: TypeAlias = Callable[[T], U]
@@ -0,0 +1,3 @@
1
+ from stdlibx.itertools._iterable import collect, filter_, filter_none, map_, reduce
2
+
3
+ __all__ = ["collect", "filter_", "filter_none", "map_", "reduce"]
File without changes