Dear all,I have a requirement that makes me think that I need to "mass patch" some ORM objects. However, I am open to any suggestions regarding the way to answer my requirements.I have defined an ORM object which represents a user, holding longitude and latitude (among other attributes). At some point, I want to query many of those users, and send them back holding the geographical distance from a certain point (defined by longitude and latitude) along with their other data.Computing the distance is computationally heavy, and I noticed that I could greatly improve performance by mass computing those distances, using numpy for example.My question is: would it be possible to split my flow in 2 :- a flow that queries the data that is simply available in the database, as ORM entities- a flow that queries lon/lat as a numpy array, perform the distance computationand afterward merge those 2 in the queried ORM entities?
It is important to me that I finally get back a list of ORM entities fully populated, because my whole downstream process is built around this assumption.Thanks a lot for your insights on the matter!Regards,PierrePS: giving me a "SQLAlchemy fast distance computation" won't do the trick, because I have other kinds of computations that may not be optimizable this way.
--SQLAlchemy -The Python SQL Toolkit and Object Relational MapperTo post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description.---You received this message because you are subscribed to the Google Groups "sqlalchemy" group.To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+...@googlegroups.com.To view this discussion on the web visit https://groups.google.com/d/msgid/sqlalchemy/CAH4TWVuJWP9WsSYNScPH%2BK9JJ3PqbOwxkm%3D_PXbPtYXzpBdvcg%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sqlalchemy/f7dcbd42-0509-46c5-b668-1a15a4834cab%40app.fastmail.com.
Thanks a lot for the insight Mike,My question might then be quite naive: let's say I have a list of ORM entities on one side, and an accordingly sorted numpy array of computed features, how would I merge back attributes on entities?Let's say I have a list like :user_list = [User(id=1, dist=None), User(id=2, dist=None)]and a pandas DataFrame (or numpy array) like:dist_df =id dist1 1232 90How would I correlate those 2 into:[User(id=1, dist=123), User(id=2, dist=90)]Would the way to go be a simple for loop? Like:for user in user_list:user.dist = dist_df.loc[user.id, 'dist']Or is there something included in SQLAlchemy for this kind of task?
To view this discussion on the web visit https://groups.google.com/d/msgid/sqlalchemy/CAH4TWVtgCh%2Bi3H2rF2js5rLsOSwfE%3DZF_zA%2BVxy03_iy-ab7NA%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sqlalchemy/052a4fc8-22b5-4acd-afdc-49adcbc924df%40app.fastmail.com.