113432864959196115

Published: Tue 05 November 2024
Updated: Tue 05 November 2024
By me

In misc.

What if python had time travel?

Like in a webapp, a common pattern is to fetch some object from the db, give them to a template, loop over them and display them.

Django provides an ORM to abstract db operations. It lets me when I display an object use related properties. If I didn't take that into account, it will make one query per object to fetch each related values.

what if when I need that related property, I could emit my need and apply it when I query the db. With compiler sorting stuff

In this exemple, when I query the db, I would open like a time window. Then when I try to access an attribute of an object from the db, the ORM would open that time window and add code to prefetch the attribute.

When compiling my source into bytecode, python would put the code defined when trying to access the attribute in the time window opened when defining the query.

I think it would be fun and solve novel problem

links

social