pmb: (Default)
[personal profile] pmb
  • I remain skeptical of quite a few things that Hillary Clinton stands for - increased censorship is pretty much always wrong, and she's too willing to roll over and find the "middle ground" between the centrist position and the loony right - but linking the federal minimum wage to the congressional wage is a stroke of genius.
  • 12 catches of 5 clubs. And I could count them myself instead of having someone else tell me how many I got. That was most pleasing.
  • Conference submission date is May 16th. Work work work. Then I am done with the research project that is turning out to be kind of orthogonal to the research I want to do. Then it's all area exam all the time. Work work work. Then the term is over.
  • And this summer I am teaching "Intro to Programming" in Python in a 4-week intensive (7/24-8/16). Using John Zelle's book based on the advice of several people. I am psyched. The rest of the summer is going to be spent biking and hanging out and reading and recovering from a relatively rough year of grad school.
From: [identity profile] pmb.livejournal.com
Python lists seem to be pretty fast.
import random
import time

for p in range(6,21):
    a = [ 1 for _ in range(2**p) ]

    elements = [ random.randint(0,len(a)-1) for _ in range(1024) ]
    s = time.time()
    for e in elements:
        _ = a[e]
    e = time.time()
    print s - e, 2**p


Gives us:
-0.000524997711182 64
-0.000507831573486 128
-0.000765085220337 256
-0.000565767288208 512
-0.000520944595337 1024
-0.000524997711182 2048
-0.000566005706787 4096
-0.00064492225647 8192
-0.000647068023682 16384
-0.000678777694702 32768
-0.000730991363525 65536
-0.000707864761353 131072
-0.000710010528564 262144
-0.000735998153687 524288
-0.000744104385376 1048576


So list access time does grow, but it's pretty miniscule and probably due to CPU cache issues, and it is *certainly* is a far cry from O(n).
From: [identity profile] pmb.livejournal.com
Underscore is a good trash variable name. I highly recommend adopting it in your own code. You might call something else i, or j, or foo, or tmp, but you'll never ever want to put a variable named _ in some kind of expression. So it's reserved for trash space. Values that are calculated but never ever used.
for _ in range(10): print "monkey"
is a nice example. Syntax requires a name there, but we never need or want to refer to it ever again, so give it the trash name.

Profile

pmb: (Default)
pmb

October 2009

S M T W T F S
    1 23
45678910
11121314151617
18192021222324
25262728293031

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Mar. 30th, 2026 11:09 am
Powered by Dreamwidth Studios