Python¼¸ÖÖ²¢·¢ÊµÏÖ·½°¸µÄÐÔÄܱȽÏ
#!/Library/Frameworks/Python.framework/Versions/2.5/bin/python
# encoding: utf-8
import sys, time
import thread
SLEEP_TIME = 0.0001
def run_benchmark(n, m):
# print(">> Python 2.5.1, stackless 3.1b3 here (N=%d, M=%d)!\n" % (n, m))
locks = [thread.allocate_lock() for i in xrange(n)]
firstP = cin = []
cin_lock_id = 0
for s in xrange(1, n):
seqn = s
cout = []
cout_lock_id = s
# print("*> s = %d" % (seqn, ))
thread.start_new_thread(loop, (seqn, locks, cin, cin_lock_id, cout, cout_lock_id))
cin = cout
cin_lock_id = cout_lock_id
else:
seqn = s+1
# print("$> s = %d" % (seqn, ))
thread.start_new_thread(mloop, (seqn, locks, cin, cin_lock_id))
for r in xrange(m-1, -1, -1):
# print("+ sending Msg# %d" % r)
lock = locks[0]
lock.acquire()
firstP.append(r)
lock.release()
time.sleep(SLEEP_TIME)
try:
while True:
time.sleep(SLEEP_TIME)
except:
pass
def loop(s, locks, cin, cin_lock_id, cout, cout_lock_id):
while True:
lock = locks[cin_lock_id]
lock.acquire()
if len(cin) > 0:
r = cin.pop(0)
lock.release()
else:
&n
Ïà¹ØÎĵµ£º
PythonÇ¿µÄ¹¦ÄܾÍÔÚÓÚËüÎÞËù²»ÄÜ¡£
ʹÓÃwin32comÄ£¿é¿ª·¢window ActiveXµÄʾÀý£º£¨Èç¹ûÄ㻹ûÓÐ×°win32comÄ£¿éµÄ»°£¬Çëµ½http://python.net/crew/skippy/win32/Downloads.htmlÏÂÔØ£©¡£
# SimpleCOMServer.py
class PythonUtilities:
_public_methods_ = ['SplitString']
_reg_progid_ = "Python.Utilities"
......
2005-2006ѧÄêµÚ1ѧÆÚ
±à Òë Ô Àí
¿Î ³Ì Éè ¼Æ ±¨ ¸æ
°à¼¶ 02¼Æ(¶þ)
ѧºÅ 19
ÐÕÃû ÁõÏþÃ÷
³É¼¨
Ö¸µ¼½Ìʦ ¬³¯»Ô
Ò»¡¢ Éè¼ÆÄ¿µÄ
¼ÓÉî¶Ô±àÒ ......
֪ʶµã
1.Ïß³ÌÊÇ“ÇáÁ¿¼¶”½ø³Ì£¬ÒòΪÏà½ÏÓÚ½ø³ÌµÄ´´½¨ºÍ¹ÜÀí£¬²Ù×÷ϵͳͨ³£»áÓýÏÉÙµÄ×ÊÔ´À´´´½¨ºÍ¹ÜÀíÏ̡߳£²Ù×÷ϵͳҪΪн¨µÄ½ø³Ì·ÖÅäµ¥¶ÀµÄÄÚÔÚ¿Õ¼äºÍÊý¾Ý£»Ïà·´£¬³ÌÐòÖеÄÏß³ÌÔÚÏàͬµÄÄÚ´æ¿Õ¼äÖÐÖ´ÐУ¬²¢¹²ÏíÐí¶àÏàͬµÄ×ÊÔ´¡£¶àÏ̳߳ÌÐòÔÚ½áÄÚ´æµÄʹÓÃЧÂÊÒªÓÅÓÚ¶à½ø³Ì³ÌÐò¡£
2.pythonÌṩÁËÍêÕûµÄ¶àÏß ......
PythonÖк¯Êý²ÎÊýµÄ´«µÝÊÇͨ¹ý“¸³Öµ”À´´«µÝµÄ¡£µ«ÕâÌõ¹æÔòÖ»»Ø´ðÁ˺¯Êý²ÎÊý´«µÝµÄ“Õ½ÂÔÎÊÌ┣¬²¢Ã»Óлشð“Õ½ÊõÎÊÌ┣¬Ò²¾Í˵ûÓлشðÔõô¸³ÖµµÄÎÊÌâ¡£º¯Êý²ÎÊýµÄʹÓÿÉÒÔ·ÖΪÁ½¸ö·½Ã棬һÊǺ¯Êý²ÎÊýÈçºÎ¶¨Ò壬¶þÊǺ¯ÊýÔÚµ÷ÓÃʱµÄ²ÎÊýÈçºÎ½âÎöµÄ¡£¶øºóÕßÓÖÊÇÓÉÇ°Õß¾ö¶¨µÄ¡£º¯Êý²ÎÊýµÄ¶¨ ......
PEP 0263
Defining Python Source Code Encodings
Python will default to ASCII as standard encoding if no other
encoding hints are given.
To define a source code encoding, a magic comment must
be placed into the source files either as first or second
line in the file, suc ......