Feature Requests item #1618676, was opened at 2006-12-19 12:08
Message generated for change (Comment added) made by jettlogic
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=1618676&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
>Status: Closed
Resolution: None
Priority: 5
Private: No
Submitted By: JettLogic (jettlogic)
Assigned to: Nobody/Anonymous (nobody)
Summary: Promote list comprehensions to Language Integrated Query?

Initial Comment:
Hi,

A feature idea (shall put to mailing list discussion sometime), is to extend 
list comprehensions to many uses of SQL or XQuery unnecessary.  

The benefit of language integration over passing SQL/XQuery strings to external 
libraries would be making code agnostic to the source of the data: in-memory 
tables and trees could be queried just like a relational DB or XML.  An "order 
by" could be more efficient than sorted(f(x) for x in y).

Of course list comprehensions do much of the C#-style LINQ already, but they 
can't (easily) do joins or "select x from a, y from b" type queries, or return 
XML a la XQuery.    

On the library side, DBAPI helps make code independent of any particular 
database, and sqlite in 2.5 means in-memory tables (lists of tuples) aren't 
really necessary.

If worthwhile, implementation would probably be best suited to PyPy.

C# Example from http://en.wikipedia.org/wiki/Language_Integrated_Query

var q = from o in db.Orders, c in db.Customers
    where o.Quality == "200" && (o.CustomerID == c.CustomerID)
    select new { o.DueDate, c.CompanyName, c.ItemID, c.ItemName };

----------------------------------------------------------------------

>Comment By: JettLogic (jettlogic)
Date: 2006-12-22 12:25

Message:
Logged In: YES 
user_id=1345991
Originator: YES

Oh ok, I guess it's up to the Py3k discussions then to figure out LINQ.  

Funny my search for "Python Language Integrated Query" didn't turn up much
(at least not the Py3k list) and now my OP is #1 on Google on 2006/12/22
for the search.  Though "Python LINQ" turns up:
http://sayspy.blogspot.com/2006/02/why-python-doesnt-need-something-like.html

I suppose there's still the efficiency of having the database doing the
filter (instead of "if x > 5") and the grouping (instead of
itertools.groupby()), and the joins.

----------------------------------------------------------------------

Comment By: Josiah Carlson (josiahcarlson)
Date: 2006-12-22 07:59

Message:
Logged In: YES 
user_id=341410
Originator: NO

There have been various discussions about metasyntax proposals and Python,
see the Python-3000 mailing list for references to LINQ.  The general
answer has been "no".  Note that you can do much of what you want by
overloading operations on standard Python objects like __or__, __and__,
etc.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=1618676&group_id=5470
_______________________________________________
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to