PythonÐÔÄܲâÊÔº¯Êý
Python ÉçÇøÓоäË×Ó“Python ×Ô¼º´ø×ŵç³Ø¡£” ±ð×Ô¼ºÐ´¼Æʱ¿ò¼Ü¡£Python 2.3ÒÔºó ¡¢¾ß±¸Ò»¸ö½Ð×ö timeit µÄÍêÃÀ¼Æʱ¹¤¾ß¡£DiveIntoÖеÄÀý×Ó
>>> import timeit
>>> t = timeit.Timer("soundex.soundex('Pilgrim')",
... "import soundex")
>>> t.timeit()
8.21683733547
>>> t.repeat(3, 2000000)
[16.48319309109, 16.46128984923, 16.44203948912]
Õâ¸ö·½·¨ÓоÖÏÞÐÔ£¬ÓÐʱºòÎÒÖ»ÊÇҪͳ¼Æ·½·¨ÖÐijһ¶ÎµÄ¼Æʱ¡£Õâ¸öʱºòÓÃtime.clock»á¸ü¼Ó·½±ã¡£ÀàËÆ.NETÖеÄstopwatch
import time
n = 100000
st = time.clock()
v = ('abcd',100,1.0, ['pumaboyd',100,None])
for i in range(n):
exec(dumps(v))
print 'pickle usage', time.clock() - st
Ïà¹ØÎĵµ£º
ÒÔÏÂÊÇÒ»¸öͨ¹ýminidomÄ£¿éдÎļþµÄÍêÕûʾÀý£¬ÊÇÔÚ×î½ü×öµÄÏîÄ¿WalleÉÏÃæÓõ½µÄ,Õâ¸öʾÀýµÄÄ¿µÄÊÇÉú³ÉÒ»¸öÈçϵĸñʽµÄxml£¬Îļþ¸ñʽΪÎÞBOM utf-8¡£
Éú³ÉxmlÎļþ¸ñʽ£º
<?xml version="1.0" encoding="utf-8"?>
<coverages>
<coverage>
  ......
Ò»¡¢pythonÊÇʲô£¿
Æäʵ£¬python¾ÍÊÇÒ»Ãűà³ÌÓïÑÔ£¬¾ÍÏñjavaÒ»Ñù¡£±¾À´ÊÇÔÚµçÄÔÉϵģ¬µ«ÊÇËæ×ÅÊÖ»úµÄÁ÷ÐУ¬python±»ÒÆÖ²µ½ÁËÊÖ»úÉÏ£¬Í¬Ê±Ò²±»ÃüÃûΪpyS60¡£
¶þ¡¢pyÈí¼þµÄ¹¹Ôì
ËùÓеÄpyÈí¼þ¶¼Òª°üÀ¨ÈçÏÂÎļþ£º.app--1.65k£».rsc--337b£».aif¡£ÕâÈý¸öÎļþÔÚËùÓÐpyÈí¼þÖж¼ÊÇÏàͬµÄ£¬Î¨Ò»µÄÇø±ð¾ÍÊÇÈí¼þµÄuid²»Í¬¡£ÕâЩÎļ ......
#!/usr/bin/env python2
import pcap
import sys
import string
import time
import socket
import struct
protocols={socket.IPPROTO_TCP:'tcp',
socket.IPPROTO_UDP:'udp',
socket ......
£ª javaÇ¿ÖÆʹÓÃOO½øÐÐÓ¦Óÿª·¢£¬Python¿ÉÒÔÓú¯Êýʽ±à³Ì¡£º¯ÊýʽÓÐʱÏԵ÷dz£¼òµ¥£¬´úÂëÁ¿¾Þ¼õ¡£»ØÏëÆðJava¶¯²»¶¯µÄN²ã¡¢»¹ÓÐÒ»¸ö¸ö¶ÔÏó£¬ÕæµÄÓÐÄÇÖÖÐÄÒªÂ𣿶øÇÒPython±¾ÉíÓïÑÔ·ç¸ñ¾Í¼ò½à£¬ÔÙ¼ÓÉϼò½àµÄº¯Êý£¬ÔÚ¿ª·¢Ð§ÂÊ¡¢Debug¡¢²âÊÔÉÏËƺõ»áÓÐÓÅÊÆ¡£
£ª ´óÐ͸´ÔÓÏîÄ¿µÄÐÔÄܸü¶àµØÌåÏÖÔڼܹ¹¡¢Ó²¼þÍØÆ˽ṹÉϵȡ£Ó¦¶Ô ......
×ÛÊö
¶àÏß³ÌÊdzÌÐòÉè¼ÆÖеÄÒ»¸öÖØÒª·½Ã棬ÓÈÆäÊÇÔÚ·þÎñÆ÷Deamon³ÌÐò·½Ãæ¡£ÎÞÂÛºÎÖÖϵͳ£¬Ï̵߳÷¶ÈµÄ¿ªÏú¶¼±È´«Í³µÄ½ø³ÌÒª¿ìµÃ¶à¡£
Python¿ÉÒÔ·½±ãµØÖ§³Ö¶àÏ̡߳£¿ÉÒÔ¿ìËÙ´´½¨Ï̡߳¢»¥³âËø¡¢ÐźÅÁ¿µÈµÈÔªËØ£¬Ö§³ÖÏ̶߳Áдͬ²½»¥³â¡£ÃÀÖв»×ãµÄÊÇ£¬PythonµÄÔËÐÐÔÚPython
ÐéÄâ»úÉÏ£¬´´½¨µÄ¶àÏß³Ì¿É ......