[ python-Feature Requests-1618676 ] Promote list comprehensions to Language Integrated Query?

SourceForge.net noreply at sourceforge.net
Fri Dec 22 06:59:11 CET 2006


Feature Requests item #1618676, was opened at 2006-12-19 02:08
Message generated for change (Comment added) made by josiahcarlson
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: Open
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: Josiah Carlson (josiahcarlson)
Date: 2006-12-21 21: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


More information about the Python-bugs-list mailing list