¡@

Home 

python Programming Glossary: t2

timeit versus timing decorator

http://stackoverflow.com/questions/1622943/timeit-versus-timing-decorator

code snippet368.html''' t1 time.time res func arg kw t2 time.time return t2 t1 res func.func_name return wrapper @timing_val.. t1 time.time res func arg kw t2 time.time return t2 t1 res func.func_name return wrapper @timing_val def time_izip..

python class attribute

http://stackoverflow.com/questions/2923579/python-class-attribute

class base def __init__ self pass derived_val 1 t1 base t2 base t2.derived_val 1 t2.__class__.derived_val 2 print t2.derived_val.. base def __init__ self pass derived_val 1 t1 base t2 base t2.derived_val 1 t2.__class__.derived_val 2 print t2.derived_val.. self pass derived_val 1 t1 base t2 base t2.derived_val 1 t2.__class__.derived_val 2 print t2.derived_val # its value is..

String concatenation vs. string substitution in Python

http://stackoverflow.com/questions/376461/string-concatenation-vs-string-substitution-in-python

'so_q_sub 1000 ' 'from __main__ import so_q_sub' t2 timeit.Timer 'so_q_cat 1000 ' 'from __main__ import so_q_cat'.. so_q_cat' t1.timeit number 10000000 12.166618871951641 t2.timeit number 10000000 5.7813972166853773 t1.timeit number 1.. t1.timeit number 1 1.103492206766532e 05 t2.timeit number 1 8.5206360154188587e 06 def so_q_tmp n ... return..

python equivalent of filter() getting two output lists (i.e. partition of a list)

http://stackoverflow.com/questions/4578590/python-equivalent-of-filter-getting-two-output-lists-i-e-partition-of-a-list

# partition is_odd range 10 0 2 4 6 8 and 1 3 5 7 9 t1 t2 tee iterable return filterfalse pred t1 filter pred t2 The recipe.. t1 t2 tee iterable return filterfalse pred t1 filter pred t2 The recipe comes from the Python 3.x documentation. In Python..

Pairs from single list

http://stackoverflow.com/questions/4628290/pairs-from-single-list

s time.time for i in range 1000 p f A for a b in p pass t2 time.time s print t1 t2 t2 t1 These were the results on my computer.. range 1000 p f A for a b in p pass t2 time.time s print t1 t2 t2 t1 These were the results on my computer 1.48668909073 2.63187503815.. 1000 p f A for a b in p pass t2 time.time s print t1 t2 t2 t1 These were the results on my computer 1.48668909073 2.63187503815..

NumPy: calculate averages with NaNs removed

http://stackoverflow.com/questions/5480694/numpy-calculate-averages-with-nans-removed

1 mm.filled np.nan N 2 t1 Timer method1 setupstr .timeit N t2 Timer np.mean l for l in d if not np.isnan l for d in dat setupstr.. N print 'Time f tRatio f' t1 t1 t1 print 'Time f tRatio f' t2 t2 t1 print 'Time f tRatio f' t3 t3 t1 print 'Time f tRatio.. 'Time f tRatio f' t1 t1 t1 print 'Time f tRatio f' t2 t2 t1 print 'Time f tRatio f' t3 t3 t1 print 'Time f tRatio f'..

Python removing duplicates in lists

http://stackoverflow.com/questions/7961363/python-removing-duplicates-in-lists

know what to do. def remove_duplicates t 'a' 'b' 'c' 'd' t2 'a' 'c' 'd' for t in t2 t.append t.remove return t python .. t 'a' 'b' 'c' 'd' t2 'a' 'c' 'd' for t in t2 t.append t.remove return t python share improve this question..

Algorithm to Divide a list of numbers into 2 equal sum lists

http://stackoverflow.com/questions/890171/algorithm-to-divide-a-list-of-numbers-into-2-equal-sum-lists

def make_teams que que.sort if len que 2 que.insert 0 0 t1 t2 while que val que.pop que.pop if sum t1 sum t2 t2.append val.. 0 0 t1 t2 while que val que.pop que.pop if sum t1 sum t2 t2.append val 0 t1.append val 1 else t1.append val 0 t2.append.. 0 0 t1 t2 while que val que.pop que.pop if sum t1 sum t2 t2.append val 0 t1.append val 1 else t1.append val 0 t2.append..

How to convert strings into integers in python?

http://stackoverflow.com/questions/642154/how-to-convert-strings-into-integers-in-python

integers and put it back nicely to list of lists this time T2 13 17 18 21 32 7 11 13 14 28 1 5 6 8 15 16 I tried to achieve..

python factory functions compared to class

http://stackoverflow.com/questions/901892/python-factory-functions-compared-to-class

'from __main__ import maker' T1.timeit 1.2818338871002197 T2 timeit.Timer 'clsmaker 3 4 ' 'from __main__ import clsmaker'.. 'clsmaker 3 4 ' 'from __main__ import clsmaker' T2.timeit 2.2137160301208496 This may be due to there being fewer..

IronPython integration with C#/ .NET

http://stackoverflow.com/questions/9053268/ironpython-integration-with-c-net

site CodeContext context TFuncType func T0 arg0 T1 arg1 T2 arg2 T3 arg3 at System.Dynamic.UpdateDelegates.UpdateAndExecute6.. at System.Dynamic.UpdateDelegates.UpdateAndExecute6 T0 T1 T2 T3 T4 T5 TRet CallSite site T0 arg0 T1 arg1 T2 arg2 T3 arg3.. T0 T1 T2 T3 T4 T5 TRet CallSite site T0 arg0 T1 arg1 T2 arg2 T3 arg3 T4 arg4 T5 arg5 at IronPython.Runtime.Importer.Import..

Use blocks from included files for parent in jinja2

http://stackoverflow.com/questions/9624953/use-blocks-from-included-files-for-parent-in-jinja2

block t2 endblock block t2_container root File T2 extends 't1.djhtml' from 't3.djhtml' import inner inner2 with..