Releases: TahsinCr/python-linqex
Releases · TahsinCr/python-linqex
v2.0
[2.0] - 13.03.2026
The "High-Performance & Production-Ready" release. This version marks a complete architectural rewrite from early 1.x experiments, delivering a structurally flawless, 100% type-safe, and memory-efficient implementation of C# LINQ for Python 3.9+.
Added
-
Core Deferred Execution Engine (
Enumerable):- Implemented a pure lazy-evaluation architecture utilizing Python's native
yieldanditertoolsC-extensions. Computations are completely deferred until a terminal operation (e.g.,to_list(),count()) is invoked. - Integrated strict
__slots__ = ('_source',)usage across all collection classes to enforce an$O(1)$ memory footprint and prevent dynamic__dict__allocations during massive data stream processing.
- Implemented a pure lazy-evaluation architecture utilizing Python's native
-
Complete LINQ API Parity:
-
Projection & Filtering:
select,select_with_index,where,where_with_index,select_many,of_type,cast. -
Partitioning:
take,skip,take_while,skip_while,take_last,skip_last, and the modern .NETchunkmethod. -
Set Operations:
distinct,distinct_by,union,union_by,intersect,intersect_by,except_for,except_by. -
Joins & Grouping: Pure memory-efficient
$O(N)$ implementations ofjoin(Inner Join),group_join, andgroup_by. -
Element Operators:
first,last,single,element_at(including their safe_or_defaultcounterparts). -
Aggregates & Quantifiers:
count,sum,max,max_by,min,min_by,average,aggregate,any,all,contains,sequence_equal.
-
Projection & Filtering:
-
Advanced Sub-Collections:
-
OrderedEnumerable: Provides stable, multi-level sorting utilizing Python's Timsort algorithm. Supports seamless method chaining viathen_byandthen_by_descendingwithout re-evaluating the entire source generator. -
GroupedEnumerable: Wraps grouped sequence outputs, providing direct.keyattribute access identical to C#'sIGrouping<TKey, TElement>.
-
-
Static Generator Methods:
- Added
Enumerable.range(start, count),Enumerable.repeat(element, count), andEnumerable.empty()for declarative sequence generation.
- Added
-
Absolute Type Safety:
- Meticulously annotated every class and method using
typinggenerics (Generic[T],TypeVar,Callable,Sequence). This guarantees flawless IDE autocompletion and strict static analysis support (mypy).
- Meticulously annotated every class and method using
Updated
-
Pythonic Fast-Paths (Algorithmic Optimizations):
- Engineered smart-type checking (
isinstance(x, Sequence)andhasattr(x, "__len__")) inside core methods likeelement_at,count,element_at_or_default, andreverse. - If the source is an in-memory collection (like a
listortuple), the engine completely bypasses$O(N)$ isliceornext()traversal, executing the operation in$O(1)$ constant time.
- Engineered smart-type checking (
-
Dictionary and Lookup Evolutions:
-
to_lookup: Now utilizescollections.defaultdictto create robust, memory-safe in-memory indexes where keys map toEnumerablevalues. -
to_dict: Now provides exact C#.ToDictionary()behavior.
-
Fixed
- C# Strict Exception Parity:
- Hardened terminal operations to throw appropriate standard Python exceptions mirroring C# behavior.
to_dictnow actively monitors for duplicate keys and throws a descriptiveValueErrorto prevent silent data overwrites.single()andsingle_or_default()now correctly throwValueErrorif the sequence contains more than one element.- Empty sequences now properly throw
ValueErroronfirst(),last(),average(),min(), andmax().
- Generator Exhaustion & Edge Cases:
- Solved chunking dimensional bugs and
skip_lastpointer window issues when dealing with forward-only iterators.
- Solved chunking dimensional bugs and
- Test Infrastructure:
- Built a completely independent, exhaustive unit testing suite.
- Reached 100% Code Coverage, specifically targeting edge cases, generator vs. list behavior differences, fallback mechanisms, and exception triggers.