Skip to main content

Linq for Python. Now supports Python 3

Project description

=============
py-linq
=============
LINQ (Language Integrated Query) is a popular querying language available in .NET. This library ports the language so
that developers can query collections of objects using the same syntax. This library would be useful for Python developers
with experience using the expressiveness and power of LINQ.

Install
-------
Available as a package from PyPI.
::
pip install py-linq

Usage
-----
To access the LINQ functions an iterable needs to be wrapped by the Enumerable class.
::
from py_linq import Enumerable
my_collection = Enumerable([1,2,3])

Executing Functions
-------------------
Similar to LINQ in C#, there are certain functions in py-linq that cause the query expression to be evaluated.

The following functions will execute an Enumerable query expression:

1. to_list
2. count
3. sum
4. min
5. max
6. avg
7. median
8. any -- uses count in algorithm
9. elementAt -- has to store data in list to allow resetting of iterator
10. elemantAtOrDefault --uses elementAt
11. first --uses elementAt
12. first_or_default --uses first
13. last --uses first after sorting
14. last_or_default --uses last
15. contains --uses any
16. group_by -- due to grouped iterables having to be saved to memory when iterating through itertools.groupby result
17. distinct -- uses group by in algorithm
18. group_join -- uses group by in algorithm
19. union -- uses distinct in algorithm



Available Functions
-------------------
Similar to LINQ, py-linq makes extensive use of Python lambda expressions as function parameters.

Most of the standard LINQ functions are available from the Enumerable class:

**Non excecuting functions**

1. select
2. order_by
3. order_by_descending
4. skip
5. take
6. where
7. select_many
8. add
9. concat
10. join
11. intersect
12. except_

**Executing functions**

13. to_list
14. count
15. sum
16. min
17. max
18. avg
19. median
20. any -- uses count in algorithm
21. elementAt -- has to store data in list to allow resetting of iterator
22. elemantAtOrDefault --uses elementAt
23. first --uses elementAt
24. first_or_default --uses first
25. last --uses first after sorting
26. last_or_default --uses last
27. contains --uses any
28. group_by -- due to grouped iterables having to be saved to memory when iterating through itertools.groupby result
29. distinct -- uses group by in algorithm
30. group_join -- uses group by in algorithm
31. union -- uses distinct in algorithm

Please refer to the MSDN `Enumerable <http://msdn.microsoft.com/en-us/library/system.linq.enumerable_methods(v=vs.100).aspx>`_
class for more information on how to use each function or view the Enumerable class `source <https://github.com/viralogic/py-enumerable/blob/master/py_linq/py_linq.py>`_ code.


=======
History
=======

30-Jan-2017 Added Python 3 support
15-Jan-2015 Changed README.rst
Performance optimizations

12-Jan-2015 Added documentation
07-Jan-2015 Initial beta release

=======
Authors
=======

Bruce Fenske

Contributors
============

Oleg Shilo

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

py-linq-0.4.0.zip (11.9 kB view details)

Uploaded Source

File details

Details for the file py-linq-0.4.0.zip.

File metadata

  • Download URL: py-linq-0.4.0.zip
  • Upload date:
  • Size: 11.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for py-linq-0.4.0.zip
Algorithm Hash digest
SHA256 cb9e0a180b444f5904af799e33a5deeda284025cec9b7bd9fd48df0d2ebdd29a
MD5 6555f2b137de6fa9d107ddba73acaf79
BLAKE2b-256 c8ac06865308bd32445db8b0546662620b5cbde3b1abb58467c7f7261a4bd0b7

See more details on using hashes here.

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