python Programming Glossary: s'import
latin-1 to ascii http://stackoverflow.com/questions/1382998/latin-1-to-ascii 10.5 and system Python 2.5 quite repeatably python mtimeit s'import a' 'a.ae ' 100000 loops best of 3 7.5 usec per loop python mtimeit.. ' 100000 loops best of 3 7.5 usec per loop python mtimeit s'import a' 'a.ud ' 100000 loops best of 3 3.66 usec per loop python.. ' 100000 loops best of 3 3.66 usec per loop python mtimeit s'import a' 'a.tr ' 10000 loops best of 3 21.4 usec per loop translate..
Python: removing characters except digits from string http://stackoverflow.com/questions/1450897/python-removing-characters-except-digits-from-string the performance difference is impressive... python mtimeit s'import string all string.maketrans nodig all.translate all string.digits.. 1000000 loops best of 3 1.04 usec per loop python mtimeit s'import re x aaa12333bb445bb54b5b52 ' 're.sub r D x '100000 loops best.. However putting this in xx.py we have... python3.1 mtimeit s'import re x aaa12333bb445bb54b5b52 ' 're.sub r D x ' 100000 loops best..
Why program functionally in Python? http://stackoverflow.com/questions/1892324/why-program-functionally-in-python sacrificing compactness and readability... python mtimeit s'import operator L range 12 52 ' 'reduce operator.mul L 1 ' 100000 loops..
Python: removing duplicates from a list of lists http://stackoverflow.com/questions/2213923/python-removing-duplicates-from-a-list-of-lists we can run checks on the tiny example list python mtimeit s'import nodup' 'nodup.doset nodup.k ' 100000 loops best of 3 11.7 usec.. ' 100000 loops best of 3 11.7 usec per loop python mtimeit s'import nodup' 'nodup.dosort nodup.k ' 100000 loops best of 3 9.68 usec.. ' 100000 loops best of 3 9.68 usec per loop python mtimeit s'import nodup' 'nodup.dogroupby nodup.k ' 100000 loops best of 3 8.74..
Iterate over the lines of a string http://stackoverflow.com/questions/3054604/iterate-over-the-lines-of-a-string strings for more precise measurement python mtimeit s'import asp' 'list asp.f3 ' 1000 loops best of 3 370 usec per loop python.. ' 1000 loops best of 3 370 usec per loop python mtimeit s'import asp' 'list asp.f2 ' 1000 loops best of 3 1.36 msec per loop.. ' 1000 loops best of 3 1.36 msec per loop python mtimeit s'import asp' 'list asp.f1 ' 10000 loops best of 3 61.5 usec per loop..
|