On 2008-04-21 17:06:39 -0600, Bob Greschke <[EMAIL PROTECTED]> said:
On 2008-04-21 16:51:13 -0600, Bob Greschke <[EMAIL PROTECTED]> said:
JUST COMPLETELY IGNORE THAT LAST ONE. What a dope. Here:
#! /usr/bin/env python
from os import system
from struct import unpack
print "unpack 1"
system("date")
for x in xrange(0, 100000000):
Value = unpack(">B", "a")[0]
if Value > 0x800000:
Value -= 0x1000000
system("date")
print
print "ord 1"
system("date")
for x in xrange(0, 100000000):
Value = ord("a")
if Value > 0x800000:
Value -= 0x1000000
system("date")
print
print "unpack 3"
system("date")
for x in xrange(0, 100000000):
Value1, Value2, Value3 = unpack(">BBB", "abc")
Value = (Value1 << 16)+(Value2 << 8)+Value3
if Value > 0x800000:
Value -= 0x1000000
system("date")
print
print "ord 3"
system("date")
for x in xrange(0, 100000000):
Value = (ord("a") << 16)+(ord("b") << 8)+ord("c")
if Value > 0x800000:
Value -= 0x1000000
system("date")
Still, the differences between unpack and ord are significant (I just
threw in the if's for fun).
I just ran this on my SunBlade 1000 with 2.3.4 and
unpack 1: 7m53s
ord 1: 2m00s
unpack 3: 14m20s
ord 3: 5m30s
timeit looks broken somehow to me.
--
http://mail.python.org/mailman/listinfo/python-list