> > another things i noted:
> > - using "value.lower() == value" instead of value.islower()
> >
> > - ansisql.py:
> > in _requires_quotes():
> > this
> > " bool(len([x for x in str(value)
> > if x not in self._legal_characters()])) "
> > should be same as
> > bool( s.translate( 256*' ', self._legal_characters() ) )
> > and that table(256) can be a static/global.
>
> oh no those are great, and should be fixed. the only ones i dont
> want to use are map() and reduce() since guido has said that list
> comprehensions should be used instead. i tend to not memorize all
> the little tweaky functions like these (note that I am frequently
> coming out against "humane" interfaces since i am more of a thinker
> and less of a memorizer). one reason you wont see too much
> performance gain with those in particuilar is because the quoting
> system caches all the decisions it makes about identifiers.
hmmm.
i run 300 times a query, and it gets something like
#calls
47026 __generic_obj_format
called from:
ansisql.py:929(format_label)(10530)
ansisql.py:935(format_table)(20273)
ansisql.py:942(format_column)(16223)
which is a lot. Only getattr, isinstance etc are more.
Anyway, my attempts at brainless (non-logic) optimisation show this:
- fixing a little __generic_obj_format(): ~1% gain
- replace OrderedSet( sets.Set+OrderedDict) with one over set: ~3%
- little fix of _process_froms() and append_column(): 0.5%
This is 1 setup + many times a relatively simple query.
---------- as of trunk:
2017068 function calls (1999993 primitive calls)
Ordered by: internal time
List reduced from 1631 to 15 due to restriction <15>
% ncalls tottime filename:lineno(function)
4% 810 1.030 ansisql.py:343(visit_select)
3% 134368 0.780 :0(getattr)
3% 17033 0.730 ansisql.py:208(visit_column)
3% 47026 0.690 ansisql.py:892(__generic_obj_format)
2% 44125 0.590 util.py:178(__setitem__)
2% 135420 0.570 :0(isinstance)
2% 12273 0.510 sql.py:1514(append_column)
1% 12180 0.380 interfaces.py:66(_get_context_strategy)
1% 833 0.370 base.py:553(__init__)
1% 16223 0.370 ansisql.py:933(format_column)
1% 11783 0.330 sql.py:1223(__init__)
1% 34460 0.320 sql.py:1263(accept_visitor)
1% 74135 0.320 :0(has_key)
1% 45261 0.280 :0(lower)
1% 20856 0.260 sets.py:519(add)
++++++++++++++ with my changes:
1910888 function calls (1895502 primitive calls)
Ordered by: internal time
List reduced from 1631 to 15 due to restriction <15>
% ncalls tottime filename:lineno(function)
5% 810 1.090 ansisql.py:343(visit_select)
4% 134352 0.870 :0(getattr)
3% 17033 0.770 ansisql.py:208(visit_column)
3% 47026 0.670 ansisql.py:892(__generic_obj_format)
3% 132118 0.640 :0(isinstance)
2% 12180 0.490 interfaces.py:66(_get_context_strategy)
2% 16223 0.420 ansisql.py:933(format_column)
1% 12273 0.380 sql.py:1514(append_column)
1% 13959 0.370 sql.py:1551(_process_froms)
1% 34460 0.300 sql.py:1263(accept_visitor)
1% 833 0.290 base.py:553(__init__)
1% 10530 0.290 ansisql.py:203(visit_label)
1% 20273 0.280 ansisql.py:926(format_table)
1% 42667 0.260 :0(get)
1% 30632 0.260 oset.py:8(add)
=======
definitely, not that big gain (in 3 hours).
btw, for the record, comparative time of these (x,y are strings):
9 '%s.%s' % (x,y)
12 str(x)+'.'+str(y)
16 '.'join( (str(x),str(y)))
5 x+'.'+y
9 '.'join( x,y)
same but x 3
14 '%s.%s.%s.%s.%s.%s' % (x,y , x,y, x,y)
40 str(x)+'.'+str(y)+...
34 '.'join( (str(x),str(y)...))
19 x+'.'+y+,,,
15 '.'join( x,y,...)
func calls _are_ expensive...
ciao
svil
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---