python Programming Glossary: t3
Compare object instances for equality by their attributes in Python http://stackoverflow.com/questions/1227121/compare-object-instances-for-equality-by-their-attributes-in-python self.__dict__ other.__dict__ t1 Test foo 42 t2 Test foo 42 t3 Test bar 42 print t1 t2 t3 print t1 t2 print t2 t3 It outputs.. t1 Test foo 42 t2 Test foo 42 t3 Test bar 42 print t1 t2 t3 print t1 t2 print t2 t3 It outputs 'attr2' 42 'attr1' 'foo'.. foo 42 t3 Test bar 42 print t1 t2 t3 print t1 t2 print t2 t3 It outputs 'attr2' 42 'attr1' 'foo' 'attr2' 42 'attr1' 'foo'..
Python random.sample with a generator http://stackoverflow.com/questions/12581437/python-random-sample-with-a-generator setup 'from __main__ import sample_from_iterable pop' t3 timeit.Timer stmt 'iter_sample_fast pop i ' k_size setup 'from.. number 100 100.0 print 'Using iter_sample_fast' ' 1.4f s' t3.timeit number 100 100.0 print '' I also ran a test to check..
Threading in python doesn't happen parallel http://stackoverflow.com/questions/14592531/threading-in-python-doesnt-happen-parallel 100 t2 threading.Thread target trade.update_items 101 200 t3 threading.Thread target trade.update_items 201 300 t1.start.. target trade.update_items 201 300 t1.start t2.start t3.start #t1.join #t2.join #t3.join Like the code I tried to commment.. 201 300 t1.start t2.start t3.start #t1.join #t2.join #t3.join Like the code I tried to commment out the join to prevent..
Optimized dot product in Python http://stackoverflow.com/questions/1828233/optimized-dot-product-in-python t2 timeit.Timer d2 v1 v2 from dot_product import d2 v1 v2 t3 timeit.Timer d3 v1 v2 from dot_product import d3 v1 v2 print.. t1.timeit print d2 elapsed t2.timeit print d3 elapsed t3.timeit Notice that the name of the file must be dot_product.py..
String concatenation vs. string substitution in Python http://stackoverflow.com/questions/376461/string-concatenation-vs-string-substitution-in-python ... so_q_tmp 1000 'http stackoverflow.com questions 1000' t3 timeit.Timer 'so_q_tmp 1000 ' 'from __main__ import so_q_tmp'.. 'so_q_tmp 1000 ' 'from __main__ import so_q_tmp' t3.timeit number 10000000 14.564135316080637 def so_q_join n .....
python circular imports once again (aka what's wrong with this design) http://stackoverflow.com/questions/3955790/python-circular-imports-once-again-aka-whats-wrong-with-this-design and now some usage t1 FunctionalTeam t2 DLPTeam t3 Team u1 HaskellUser u2 PythonUser t1.leader u1 # ok t2.leader.. u1 # ok t2.leader u2 # ok t1.leader u2 # not ok exception t3.leader u2 # ok # now index print Index FunctionalTeam 'leader'.. 'leader' u2 # t2 print Index Team 'leader' u2 # t2 t3 So it works great implementation details ommitted but there..
NumPy: calculate averages with NaNs removed http://stackoverflow.com/questions/5480694/numpy-calculate-averages-with-nans-removed l in d if not np.isnan l for d in dat setupstr .timeit N t3 Timer np.array r np.isfinite r .mean for r in dat setupstr .timeit.. print 'Time f tRatio f' t2 t2 t1 print 'Time f tRatio f' t3 t3 t1 print 'Time f tRatio f' t4 t4 t1 print 'Time f tRatio.. 'Time f tRatio f' t2 t2 t1 print 'Time f tRatio f' t3 t3 t1 print 'Time f tRatio f' t4 t4 t1 print 'Time f tRatio f'..
pydev breakpoints not working http://stackoverflow.com/questions/9486871/pydev-breakpoints-not-working name pydevd.writer id 1 xml 'received command ' '111 t3 tD Documents Code Eclipse workspace sqladata src testData.py..
Use blocks from included files for parent in jinja2 http://stackoverflow.com/questions/9624953/use-blocks-from-included-files-for-parent-in-jinja2 to explain this is a test case File t1.djhtml root block t3_container block t3 This should be 'CONTENT' endblock block t3_container.. a test case File t1.djhtml root block t3_container block t3 This should be 'CONTENT' endblock block t3_container block t2_container.. block t3 This should be 'CONTENT' endblock block t3_container block t2_container block t2 endblock block t2_container..
|