I am trying to optimize Python code. The profiler tells me that SQLAlchemy _get_col () is what kills performance. The code looks something like this:
lots_of_rows = get_lots_of_rows() for row in lots_of_rows: if row.x == row.y: print row.z
I was going to go through the code and make it more like this ...
lots_of_rows = get_lots_of_rows() for row in lots_of_rows: if row[0] == row[1]: print row[2]
... but I found some documentation that seems to indicate that when accessing string objects, such as arrays, you actually still pull out the dictionary keys. In other words, the string object is as follows:
'x': (x object) '0': (x object) 'y': (y object) '1': (y object) 'z': (z object) '2': (z object)
, , , . SA , ? , - - ?
, row.x == row.y? :
mytable.select().where(mytable.c.x==mytable.c.y)
. .
, row.items() - , . (, ) .
row.items()
SQLAlchemy . , . , , , ResultProxy RowProxy .
, 5US . , . dbapi. , SQLQlchemy . , , dbapi ResultProxy, result.cursor.cursor. (result.cursor - SQLAlchemy CursorFairy). dbapi fetchall(), fetchone() fetchmany().
ResultProxy
result.cursor.cursor
result.cursor
, , , . , , .
, "_get_col", , _get_col . ( _get_col ).
sqlalchemy, , lookup_key ( engine/base.py), , , , ( PopulateDict).
, .__ ( , ), , row.cursor, , , sqlalchemy ( sql) w/.
- J
Source: https://habr.com/ru/post/1704926/More articles:CSS Parser in ColdFusion or Java? - javaDon't change the color of the header text In Gridview with CSS - c #"Sys" undefined "error when starting an ASP.NET MVC application in IIS7 - asp.net-mvcHow can you select text in a div (for copy to clipboard) from javascript? - javascriptHow can I follow and fully report on a chain of symbolic links? - javaLearning MIPS as a second assembly language? - mipsHow does JIT compilation work for caching? - c #Creating an SQL Database from an ADO.NET Typed Dataset - sql-serverIs it possible to create a cursor in WPF from VisualBrush? - wpfWhat do you want the iPhone library to do for you? - iphoneAll Articles