{"id":13501624,"url":"https://github.com/avilum/linqit","last_synced_at":"2025-12-31T01:10:04.046Z","repository":{"id":49991511,"uuid":"131177293","full_name":"avilum/linqit","owner":"avilum","description":"Extend python lists operations using .NET's LINQ syntax for clean and fast coding.","archived":false,"fork":false,"pushed_at":"2023-05-22T06:51:44.000Z","size":75,"stargazers_count":248,"open_issues_count":0,"forks_count":14,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-01-10T17:30:00.060Z","etag":null,"topics":["awesome","batch-processing","clean","clean-code","csharp","development-tools","dotnet","efficiency","filters","lazy-loading","linq","metadata","metaprogramming","powerful","python","python3","pythonic","robustness","syntax"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/avilum.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2018-04-26T15:40:38.000Z","updated_at":"2024-12-20T04:00:38.000Z","dependencies_parsed_at":"2024-01-16T10:37:12.989Z","dependency_job_id":"1ceb170e-2553-46ab-b75c-8d7fdff8262f","html_url":"https://github.com/avilum/linqit","commit_stats":{"total_commits":44,"total_committers":9,"mean_commits":4.888888888888889,"dds":0.4772727272727273,"last_synced_commit":"32aa8c74666350b91e518f992c28c4bbddc8a988"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avilum%2Flinqit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avilum%2Flinqit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avilum%2Flinqit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avilum%2Flinqit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/avilum","download_url":"https://codeload.github.com/avilum/linqit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238218254,"owners_count":19435844,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["awesome","batch-processing","clean","clean-code","csharp","development-tools","dotnet","efficiency","filters","lazy-loading","linq","metadata","metaprogramming","powerful","python","python3","pythonic","robustness","syntax"],"created_at":"2024-07-31T22:01:44.109Z","updated_at":"2025-10-27T13:30:40.332Z","avatar_url":"https://github.com/avilum.png","language":"Python","readme":"# Linqit!\nExtends python's list builtin with fun, robust functionality - .NET's Language Integrated Queries (Linq) and more.\u003cbr\u003e\nWrite clean code with powerful syntax.\u003cbr\u003e\u003cbr\u003e\n```shell script\npip install linqit\n```\n\u003ccenter\u003e\n\u003cimg src=\"https://img.shields.io/badge/Test Coverage-96%25-brightgreen\"\u003e\n\u003c/center\u003e\n\u003cbr\u003e\n\n\nStop using loops, complex conditions, list comprehension and filters.\u003cbr\u003e\nDoesn't it looks better? \u003cbr\u003e\n```python\nfrom linqit import List\n\n# Go ahead and fill the list with whatever you want... like a list of \u003cProgrammer\u003e objects.\nprogrammers = List()\nAvi = type(\"Avi\", (), {})\nEntrepreneur = type(\"Entrepreneur\", ('talented'), {})\nelon_musk = Entrepreneur(talented=True)\n\n# Then play:\nlast_hot_pizza_slice = (\n    programmers.where(lambda e: e.experience \u003e 15)\n    .except_for(elon_musk)\n    .of_type(Avi)\n    .take(3)  # [\u003cAvi\u003e, \u003cAvi\u003e, \u003cAvi\u003e]\n    .select(lambda avi: avi.lunch)  # [\u003cPizza\u003e, \u003cPizza\u003e, \u003cPizza\u003e]\n    .where(lambda p: p.is_hot() and p.origin != \"Pizza Hut\")\n    .last()  # \u003cPizza\u003e\n    .slices.last()  # \u003cPizzaSlice\u003e\n)\n\n# What do you think?\n```\n\nWe all use multiple aggregations in our code, while multiple filters/comprehensions are not pythonic at all.\u003cbr\u003e\nThe whole idea is is to use it for nested, multiple filters/modifications :).\u003cbr\u003e\nSome of the methods might look ridiculous for a single calls, comparing to the regular python syntax.\u003cbr\u003e\nHere are some use cases: \u003cbr\u003e\n\n#### Methods:\n```\nall\nany\nconcat\ncontains\ndistinct\nexcept_for\nfirst\nget_by_attr\nintersect\nlast\nselect\nskip\ntake\nwhere\nof_type\n```\n#### Properties:\n```\nsum\nmin\nmax\navg\nsorted\n```\n\n## Deeper - Let's play with a list of people, a custom type.\n```python\nimport List\n\nclass Person():\n    def __init__(self, name, age):\n        self.name = name\n        self.age = age\n\n    def __repr__(self):\n        return f'Person(name=\"{self.name}\", age={self.age})')\n\n\n# Creating a list of people\navi, bill, bob, harry = Person('Avi', 23), Person('Bill', 41), Person('Bob', 77), Person('Harry', 55)\n\npeople = List(avi, bill, bob, harry)\n```\n\n## Use LINQ selections, write cleaner code\n```python\npeople = people.where(lambda p: p.age \u003e 23) # [\u003cPerson name=\"Bill\" age=\"41\"\u003e, \u003cPerson name=\"Bob\" age=\"77\"\u003e, \u003cPerson name=\"Harry\" age=\"55\"\u003e]\npeople.first()                                              # \u003cPerson name=\"Bill\" age=\"41\"\u003e\npeople.last()                                               # \u003cPerson name=\"Harry\" age=\"55\"\u003e\npeople.any(lambda p: p.name.lower().startswith('b'))        # True\npeople.where(age=55)                         # [\u003cPerson name=\"Harry\" age=\"55\"\u003e]\npeople.skip(3).any()                                        # False\npeople.skip(2).first()                                      # \u003cPerson name=\"Harry\" age=\"55\"\u003e\n\n# Isn't it better than \"for\", \"if\", \"else\", \"filter\", \"map\" and list comprehensions in the middle of your code?\n\n```\n## More selections\n```python\nnew_kids_in_town = [Person('Chris', 18), Person('Danny', 16), Person('John', 17)]\npeople += new_kids_in_town # Also works: people = people.concat(new_kids_in_town)\n\nteenagers = people.where(lambda p: 20 \u003e= p.age \u003e= 13)\ndanny = teenagers.first(lambda t: t.name == 'Danny')            # \u003cPerson name=\"Danny\" age=\"16\"\u003e\noldest_teen = teenagers.order_by(lambda t: t.age).last()                                  # \u003cPerson name=\"John\" age=\"17\"\u003e\n```\n\n## Let's make python more dynamic\n```python\nnames = people.name                                             # ['Avi', 'Bill', 'Bob', 'Harry', 'Chris', 'John']\nages = people.age                                               # [23, 41, 77, 55, 18, 17]\nteenagers_names = teenagers.name                                # ['Chris', 'Danny', 'John']\nteenagers_names.take(2).except_for(lambda n: n == 'Danny')      # ['Chris']\nteenagers.age.min                                               # 16\nteenagers.age.avg                                               # 17\nteenagers.age.max                                               # 18\n```\n\n# Test Coverage\n```python\n➜  linqit git:(master) ✗ coverage report                    \nName                  Stmts   Miss  Cover\n-----------------------------------------\nlinqit/__init__.py        2      0   100%\nlinqit/linq_list.py     101     11    89%\ntests/__init__.py         0      0   100%\ntests/test_list.py      203      0   100%\n-----------------------------------------\nTOTAL                   306     11    96%\n```\n","funding_links":[],"categories":["Python"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Favilum%2Flinqit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Favilum%2Flinqit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Favilum%2Flinqit/lists"}