A Python implementation of .NET's Language Integrated Query (LINQ), providing a functional, fluent API for querying and manipulating collections.
Project description
jetq - Python LINQ
A Python implementation of .NET's Language Integrated Query (LINQ), providing a functional, fluent API for querying and manipulating collections.
Overview
jetq brings the power and elegance of C# LINQ to Python, allowing you to write expressive, chainable queries over any iterable collection.
Key Features
- Fluent API: Method chaining for readable, composable queries
- Deferred Execution: Lazy evaluation for better performance
- Rich Operators: 50+ query operators covering filtering, projection, aggregation, and more
- Type-Safe: Full type hints for IDE support and type checking
- Provider Architecture: Extensible design supporting different data sources
Installation
pip install jetq
Quick Start
from jetq import Queryable
# Basic filtering and projection
numbers = Queryable([1, 2, 3, 4, 5])
result = numbers.where(lambda x: x > 2).select(lambda x: x * 2).to_list()
# Output: [6, 8, 10]
# Grouping and aggregation
data = Queryable([
{'name': 'Alice', 'age': 30},
{'name': 'Bob', 'age': 25},
{'name': 'Charlie', 'age': 30}
])
grouped = data.group_by(lambda x: x['age']).to_list()
# Ordering
sorted_data = numbers.order_by(lambda x: -x).to_list()
# Output: [5, 4, 3, 2, 1]
Core Concepts
Queryable vs Enumerable
- Queryable: Works with any iterable, supports custom query providers
- Enumerable: In-memory extension methods for simple queries
Deferred Execution
Queries are not executed until you enumerate the results:
query = Queryable([1, 2, 3]).where(lambda x: x > 1) # Not executed yet
result = query.to_list() # Executed here
Supported Operators
Filtering
where()- Filter elements based on predicatedistinct()- Remove duplicatesskip()- Skip first N elementstake()- Take first N elements
Projection
select()- Project each elementselect_many()- Flatten nested collections
Ordering
order_by()- Sort ascendingorder_by_descending()- Sort descendingthen_by()- Secondary sortthen_by_descending()- Secondary sort descending
Grouping & Joining
group_by()- Group elements by keyjoin()- Inner joingroup_join()- Left join with grouped results
Aggregation
count()- Count elementssum()- Sum valuesaverage()- Average valuemin()- Minimum valuemax()- Maximum valueaggregate()- Custom aggregation
Set Operations
union()- Combine sequencesintersect()- Common elementsexcept_()- Difference
Element Access
first()- First elementfirst_or_default()- First or defaultlast()- Last elementsingle()- Single element (throws if != 1)element_at()- Element at index
Quantifiers
any()- Check if any element matchesall()- Check if all elements matchcontains()- Check if contains element
Conversion
to_list()- Convert to listto_dict()- Convert to dictionaryto_set()- Convert to set
Contributing
Contributions are welcome! Areas for improvement:
- Additional query operators
- Performance optimizations
- Custom provider implementations
- More comprehensive tests
License
MIT License - See LICENSE file for details
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file jetq-0.1.0.tar.gz.
File metadata
- Download URL: jetq-0.1.0.tar.gz
- Upload date:
- Size: 16.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ebbcbf934c6620868631ed960cb1c0120b89b6032f932364e3bbeea437186be3
|
|
| MD5 |
84c4cac974cf5cfea83555257c763d0d
|
|
| BLAKE2b-256 |
ae0e58aa1f2ba73bce6ec2e3e59b0a33f7e7ae65ba8080fce5528518849a5e65
|
Provenance
The following attestation bundles were made for jetq-0.1.0.tar.gz:
Publisher:
publish.yml on zoranmax/jetq
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
jetq-0.1.0.tar.gz -
Subject digest:
ebbcbf934c6620868631ed960cb1c0120b89b6032f932364e3bbeea437186be3 - Sigstore transparency entry: 953640047
- Sigstore integration time:
-
Permalink:
zoranmax/jetq@f1719c89df126d777c0a1d5b523127a862cd011b -
Branch / Tag:
refs/heads/main - Owner: https://github.com/zoranmax
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f1719c89df126d777c0a1d5b523127a862cd011b -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file jetq-0.1.0-py3-none-any.whl.
File metadata
- Download URL: jetq-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4a19df6ada8731f7f54475cb0c0ed54fc3a13a5834cc9eb023639e8c3b2fefe0
|
|
| MD5 |
d1372ea40587b7925d4acab1c99b5d53
|
|
| BLAKE2b-256 |
3aabf5122a73d0e45eca882aa60ed14d912c72065caa5db4d1ad8db5b7b61af9
|
Provenance
The following attestation bundles were made for jetq-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on zoranmax/jetq
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
jetq-0.1.0-py3-none-any.whl -
Subject digest:
4a19df6ada8731f7f54475cb0c0ed54fc3a13a5834cc9eb023639e8c3b2fefe0 - Sigstore transparency entry: 953640049
- Sigstore integration time:
-
Permalink:
zoranmax/jetq@f1719c89df126d777c0a1d5b523127a862cd011b -
Branch / Tag:
refs/heads/main - Owner: https://github.com/zoranmax
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f1719c89df126d777c0a1d5b523127a862cd011b -
Trigger Event:
workflow_dispatch
-
Statement type: