[Python-Dev] Enable access to the AST for Python code (original) (raw)
Greg greg.ewing at canterbury.ac.nz
Fri May 22 04:06:54 CEST 2015
- Previous message (by thread): [Python-Dev] Enable access to the AST for Python code
- Next message (by thread): [Python-Dev] Enable access to the AST for Python code
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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"."totalprice"), 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 different language.
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.
-- Greg
- Previous message (by thread): [Python-Dev] Enable access to the AST for Python code
- Next message (by thread): [Python-Dev] Enable access to the AST for Python code
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]