Module Expr Str Import alias Import alias Import alias Import alias Import alias Import alias Assign NameStore Call AttributeLoad NameLoad attr FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad BinOpMod Str NameLoad TryExcept body Assign NameStore Call NameLoad NameLoad Str handlers ExceptHandler type NameLoad body Assign NameStore AttributeLoad NameLoad attr Assign NameStore ListComp Call NameLoad comprehension NameStore Call NameLoad NameLoad TryExcept body TryFinally body Assign NameStore Call NameLoad NameLoad Str Expr Call AttributeLoad NameLoad attr NameLoad NameLoad Expr Call AttributeLoad NameLoad attr Assign NameStore NameLoad finalbody If NameLoad body TryExcept body Expr Call AttributeLoad NameLoad attr NameLoad handlers ExceptHandler type AttributeLoad NameLoad attr body Pass handlers ExceptHandler type NameLoad name NameStore body Print Str NameLoad Str NameLoad orelse Assign NameStore Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr For NameStore Call NameLoad Num body Assign NameStore Call AttributeLoad NameLoad attr NameLoad Assign NameStore SubscriptLoad NameLoad Slice NameLoad Delete SubscriptDel NameLoad Slice NameLoad Expr Call AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr NameLoad Delete NameDel Assert CompareEq Call NameLoad NameLoad NameLoad Return NameLoad decorator_list FunctionDef arguments args defaults body Expr Call AttributeLoad AttributeLoad NameLoad attr attr decorator_list FunctionDef arguments args NameParam defaults body Assign NameStore Call AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr Print BinOpMod Str BinOpSub NameLoad NameLoad Expr Call NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore Call NameLoad ListComp BinOpAdd NameLoad Str comprehension NameStore Str Assign NameStore BinOpAdd Str BinOpMult Str Call NameLoad NameLoad Print BinOpMod NameLoad BinOpAdd TupleLoad Str Str NameLoad For NameStore NameLoad body Assign NameStore BinOpLShift Num NameLoad Assign NameStore Call NameLoad NameLoad Print BinOpMod Str TupleLoad NameLoad NameLoad Expr Call NameLoad Expr Call NameLoad NameLoad Expr Call AttributeLoad NameLoad attr Expr Call NameLoad NameLoad Expr Call NameLoad NameLoad For NameStore Call NameLoad Num body Assign NameStore Call AttributeLoad NameLoad attr NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad Assign TupleStore SubscriptStore NameLoad Index NameLoad SubscriptStore NameLoad Index NameLoad TupleLoad SubscriptLoad NameLoad Index NameLoad SubscriptLoad NameLoad Index NameLoad Expr Call NameLoad NameLoad If CompareGtE NameLoad Num body Assign SubscriptStore NameLoad Slice Num ListComp Call AttributeLoad NameLoad attr comprehension NameStore Call NameLoad Num Expr Call NameLoad NameLoad For NameStore Call NameLoad BinOpFloorDiv NameLoad Num body Assign SubscriptStore NameLoad Index Call AttributeLoad NameLoad attr NameLoad Call AttributeLoad NameLoad attr Expr Call NameLoad NameLoad If CompareGt NameLoad Num body Delete SubscriptDel NameLoad Slice Num Assign NameStore BinOpMult NameLoad BinOpFloorDiv NameLoad Num Assign NameStore Call NameLoad Lambda arguments args NameParam defaults UnaryOpUSub UnaryOpUSub NameLoad NameLoad Expr Call NameLoad NameLoad Delete NameDel Assign NameStore Call NameLoad NameLoad BinOpMult ListLoad Num NameLoad Expr Call NameLoad NameLoad Delete NameDel Assign NameStore BinOpFloorDiv NameLoad Num Assign NameStore Call NameLoad BinOpSub NameLoad Num Num Num Expr Call AttributeLoad NameLoad attr Call NameLoad NameLoad Assign NameStore Call NameLoad NameLoad NameLoad Expr Call NameLoad NameLoad Print decorator_list FunctionDef arguments args defaults body Expr Str Assign NameStore Num Assign NameStore Num If SubscriptLoad AttributeLoad NameLoad attr Slice Num body Assign NameStore NameStore Call NameLoad SubscriptLoad AttributeLoad NameLoad attr Index Num If SubscriptLoad AttributeLoad NameLoad attr Slice Num body Assign NameStore Call NameLoad SubscriptLoad AttributeLoad NameLoad attr Index Num If SubscriptLoad AttributeLoad NameLoad attr Slice Num body Assign NameStore Num For NameStore SubscriptLoad AttributeLoad NameLoad attr Slice Num body Assign NameStore BinOpAdd BinOpMult Num NameLoad Call NameLoad NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Assign NameStore Call NameLoad NameLoad BinOpAdd NameLoad Num Expr Call NameLoad NameLoad decorator_list If CompareEq NameLoad Str body Expr Call NameLoad
N/A N/A Sort performance test.

See main() for command line syntax.
See tabulate() for output format.

 N/A sys N/A time N/A random N/A marshal N/A tempfile N/A os N/A td N/A N/A tempfile gettempdir randfloats N/A N/A n N/A N/A N/A Return a list of n random floats in [0, 1). N/A fn N/A N/A N/A os path join td N/A rr%06d n N/A N/A N/A fp N/A open fn rb N/A N/A N/A IOError N/A N/A r N/A random random N/A result N/A N/A r N/A i N/A xrange n N/A N/A N/A N/A N/A fp N/A open fn wb N/A N/A N/A marshal dump result fp N/A N/A N/A fp close N/A fp None N/A N/A fp N/A N/A N/A N/A N/A N/A os unlink fn N/A N/A N/A N/A os error N/A N/A N/A N/A N/A IOError N/A msg N/A N/A can't write fn : msg N/A N/A result N/A N/A marshal load fp N/A N/A N/A fp close N/A i N/A range 10 N/A N/A i N/A N/A random randrange n N/A temp N/A result N/A i N/A N/A result N/A i N/A N/A N/A temp reverse N/A N/A N/A result extend temp N/A temp N/A N/A N/A len result n N/A result N/A flush N/A N/A N/A N/A N/A N/A N/A N/A sys stdout flush N/A doit N/A N/A L N/A N/A N/A t0 N/A N/A time clock N/A N/A N/A L sort N/A t1 N/A N/A time clock N/A N/A %6.2f N/A t1 t0 N/A N/A flush N/A tabulate N/A N/A r N/A N/A N/A Tabulate sort speed for lists of various sizes.

    The sizes are 2**i for i in r (the argument, a list).

    The output displays i, 2**i, and the time to sort arrays of 2**i
    floating point numbers with the following properties:

    *sort: random data
    \sort: descending data
    /sort: ascending data
    3sort: ascending, then 3 random exchanges
    +sort: ascending, then 10 random at the end
    %sort: ascending, then randomly replace 1% of the elements w/ random values
    ~sort: many duplicates
    =sort: all equal
    !sort: worst case scenario

     N/A cases N/A tuple N/A N/A ch sort N/A ch *\/3+%~=! N/A fmt N/A %2s %7s N/A  %6s N/A len cases N/A N/A fmt N/A N/A i 2**i cases N/A i r N/A N/A n N/A 1 i N/A L N/A randfloats n N/A N/A %2d %7d N/A i n N/A N/A flush N/A N/A doit L N/A N/A N/A L reverse N/A N/A doit L N/A N/A doit L N/A dummy N/A range 3 N/A N/A i1 N/A N/A random randrange n N/A i2 N/A N/A random randrange n N/A N/A N/A L N/A i1 N/A L N/A i2 N/A N/A L N/A i2 N/A L N/A i1 N/A N/A doit L N/A N/A n 10 N/A N/A N/A L N/A -10 N/A N/A N/A random random N/A dummy N/A range 10 N/A N/A doit L N/A dummy N/A xrange N/A n 100 N/A N/A N/A L N/A N/A N/A random randrange n N/A N/A random random N/A N/A doit L N/A N/A n 4 N/A N/A N/A L N/A 4 N/A L N/A L N/A n 4 N/A L N/A map N/A N/A N/A x N/A N/A N/A x L N/A N/A doit L N/A L N/A L N/A map abs N/A N/A -0.5 n N/A N/A doit L N/A L N/A half N/A n 2 N/A L N/A range N/A half 1 -1 -1 N/A N/A N/A L extend N/A range half N/A L N/A map float L N/A N/A doit L N/A N/A main N/A N/A N/A N/A N/A Main program when invoked as a script.

    One argument: tabulate a single row.
    Two arguments: tabulate a range (inclusive).
    Extra arguments are used to seed the random generator.

     N/A k1 15 N/A k2 20 N/A N/A N/A sys argv N/A 1 N/A N/A k1 k2 N/A int N/A N/A sys argv N/A 1 N/A N/A N/A sys argv N/A 2 N/A N/A k2 N/A int N/A N/A sys argv N/A 2 N/A N/A N/A sys argv N/A 3 N/A N/A x 1 N/A a N/A N/A sys argv N/A 3 N/A N/A x N/A N/A 69069 x N/A hash a N/A N/A N/A random seed x N/A r N/A range k1 N/A k2 1 N/A N/A tabulate r N/A N/A N/A __name__ __main__ N/A N/A N/A main