(09-05-2014, 09:40 PM)Venatori Wrote: Very good post here! These technique's will definitely help me in my future Python endeavors!
I do have one question though. What is the actual benefit from your "raw_input()" advice?
Thank you for your good words.
Well in python 2.x sys.stdin.readline() it proves to be a little faster when its about taking inputs from the user cause it avoids some automated things that which built-in raw_input() does (like for example the '\n' striping which in some case you might don't need it). Also its good to mention here that this 'problem' is claimed to be fixed on Python3.x versions and input() function.
For example if its about to take massive inputs and use raw_input inside a loop, if you want to achieve best performance available its prefferable to use sys.stdin.readline().
I made a simple sample run for you in ipython take a look...
Spoiler: Sample Image
Although that the difference is not big, its still a difference.
Plus the difference in time can vary depending on the task you have to solve.
I hope this helps.
Sincerely,
L0aD1nG