something about performence
Hi, I have two large files,each has more than 2 lines,and each line consists of two fields,one is the id and the other a value, the ids are sorted. for example: file1 (uin_a y) 1 1245 2 12333 3 324543 5 3464565 file2 (uin_b gift) 1 34545 3 6436466 4 35345646 5 463626 I want to merge them and get a file,the lines of which consists of an id and the sum of the two values in file1 and file2。 the codes are as below: uin_y=open('file1') uin_gift=open(file2') y_line=uin_y.next() gift_line=uin_gift.next() while 1: try: uin_a,y=[int(i) for i in y_line.split()] uin_b,gift=[int(i) for i in gift_line.split()] if uin_a==uin_b: score=y+gift print uin_a,score y_line=uin_y.next() gift_line=uin_gift.next() if uin_auin_b: print uin_b,gift gift_line=uin_gift.next() except StopIteration: break the question is that those code runs 40+ minutes on a server(16 core,32G mem), the time complexity is O(n),and there are not too much operations, I think it should be faster.So I want to ask which part costs so much. I tried the cProfile module but didn't get too much. I guess maybe it is the int() operation that cost so much,but I'm not sure and don't know how to solve this. Is there a way to avoid type convertion in Python such as scanf in C? Thanks for your help :) -- http://mail.python.org/mailman/listinfo/python-list
How to save the packages received by a network interface or some port in a file and resend the packages received when needed?
hi, This is a question not specific to Python,but its related somehow,and I believe I can get some help from your fellow:) I am doing my work on a server service program on Linux that processes the packages sent to the socket it listens.Their is already a old such service listening on the port doing its job,and I can't stop the old server service, and I need to get the packages sent to the old server and send them to my new server service to make sure it works well .How can I get the package and resent them to my new service? Is there such a tool or is there some functionality that tools such as tcpdump already provides? Thanks:) -- http://mail.python.org/mailman/listinfo/python-list
Re: How to save the packages received by a network interface or some port in a file and resend the packages received when needed?
In fact,UDP is enough for me,I heared that tcpdump and netcat can store and resend the udp packages to get the replay effect,but I don't know how, or is there some better way? I am working on a Linux server and only some basic terminal tools are available :) 2011/8/31 Emile van Sebille > On 8/31/2011 6:35 AM king6c...@gmail.com said... > > hi, >> This is a question not specific to Python,but its related somehow,and >> I believe I can get some help from your fellow:) >> I am doing my work on a server service program on Linux that >> processes the packages sent to the socket it listens.Their is already a >> old such service listening on the port doing its job,and >> I can't stop the old server service, and I need to get the packages sent >> to the old server and send them to my new server service to make sure it >> works well .How can I get the package and resent them to my new service? >> Is there such a tool or is there some functionality that tools such as >> tcpdump already provides? >> > > I recently set up a standby spare fax server on a network that I also > needed to test, and was able to tee the source transmissions to both > systems. That may be an option, particularly as it sounds like you've > written a consumer of info and are not replying and interacting with the > source. > > Emile > > > > > -- > http://mail.python.org/**mailman/listinfo/python-list<http://mail.python.org/mailman/listinfo/python-list> > -- http://mail.python.org/mailman/listinfo/python-list