Skip to main content

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 predicate
  • distinct() - Remove duplicates
  • skip() - Skip first N elements
  • take() - Take first N elements

Projection

  • select() - Project each element
  • select_many() - Flatten nested collections

Ordering

  • order_by() - Sort ascending
  • order_by_descending() - Sort descending
  • then_by() - Secondary sort
  • then_by_descending() - Secondary sort descending

Grouping & Joining

  • group_by() - Group elements by key
  • join() - Inner join
  • group_join() - Left join with grouped results

Aggregation

  • count() - Count elements
  • sum() - Sum values
  • average() - Average value
  • min() - Minimum value
  • max() - Maximum value
  • aggregate() - Custom aggregation

Set Operations

  • union() - Combine sequences
  • intersect() - Common elements
  • except_() - Difference

Element Access

  • first() - First element
  • first_or_default() - First or default
  • last() - Last element
  • single() - Single element (throws if != 1)
  • element_at() - Element at index

Quantifiers

  • any() - Check if any element matches
  • all() - Check if all elements match
  • contains() - Check if contains element

Conversion

  • to_list() - Convert to list
  • to_dict() - Convert to dictionary
  • to_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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jetq-0.1.0.tar.gz (16.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jetq-0.1.0-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

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

Hashes for jetq-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ebbcbf934c6620868631ed960cb1c0120b89b6032f932364e3bbeea437186be3
MD5 84c4cac974cf5cfea83555257c763d0d
BLAKE2b-256 ae0e58aa1f2ba73bce6ec2e3e59b0a33f7e7ae65ba8080fce5528518849a5e65

See more details on using hashes here.

Provenance

The following attestation bundles were made for jetq-0.1.0.tar.gz:

Publisher: publish.yml on zoranmax/jetq

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for jetq-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4a19df6ada8731f7f54475cb0c0ed54fc3a13a5834cc9eb023639e8c3b2fefe0
MD5 d1372ea40587b7925d4acab1c99b5d53
BLAKE2b-256 3aabf5122a73d0e45eca882aa60ed14d912c72065caa5db4d1ad8db5b7b61af9

See more details on using hashes here.

Provenance

The following attestation bundles were made for jetq-0.1.0-py3-none-any.whl:

Publisher: publish.yml on zoranmax/jetq

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page