[Python-Dev] Enable access to the AST for Python code
greg.ewing at canterbury.ac.nz
Fri May 22 04:06:54 CEST 2015
On 22/05/2015 1:33 p.m., Ethan Furman wrote:
> Going back to the OP:
>> select(c for c in Customer if sum(c.orders.price) > 1000)
>> which compile into and run SQL like this:
>> SELECT "c"."id"
>> FROM "Customer" "c"
>> LEFT JOIN "Order" "order-1" ON "c"."id" = "order-1"."customer"
>> GROUP BY "c"."id"
>> HAVING coalesce(SUM("order-1"."total_price"), 0) > 1000
> That last code is /not/ Python. ;)
More importantly, it's not Python *semantics*. You can't view
it as simply a translation of the Python expression into a
I still think this is really a macro facility by a different
name. I'm not saying that's a bad thing, just pointing it out.
The main difference is that a macro would (or at least could)
be expanded at compile time, whereas this would require
processing the AST each time it's used.
More information about the Python-Dev