Change in Python 3.3 with the treatment of sys.argv

Steven D'Aprano steve+comp.lang.python at pearwood.info
Fri Mar 22 19:45:13 EDT 2013


On Fri, 22 Mar 2013 17:57:42 -0400, Colin J. Williams wrote:

> Below is an extract from some code to run on Python 2.7.3, 3.2.3 and
> 3.3.0 to compare speeds, both between versions and machines:

Do you have an actual question? I don't see the point. You've given us an 
"extract", which means the rest of your code could be doing anything, and 
the code you have provided doesn't actually run. What question are we 
supposed to be answering? Is there a problem here that needs to be solved?

I appreciate the fact that you didn't dump a huge blob of code on us, 
truly I do, but please read this page:

http://sscce.org/

for ideas on how to effectively write example code.

By the way, if you suspect a difference in sys.argv, the easiest way to 
compare the two is to *look at sys.argv alone*, with as little other 
confounding code as possible.

E.g. write this tiny two-line script:

import sys
print(sys.argv)


Then call it from the command line with something like this (tested under 
Linux, may be a little different under Windows):


python2.7 myscript.py "hello world" fe fi fo fum
python3.2 myscript.py "hello world" fe fi fo fum
python3.3 myscript.py "hello world" fe fi fo fum


In all three cases, you should get the exact same result:

['hello world', 'fe', 'fi', 'fo', 'fum']


which strongly suggests that whatever problem you are experiencing, it is 
not caused by changes in sys.argv. (There is no change in sys.argv, it's 
just a list of strings, the same as it always was.)



P.S. it's remarkably, and deceptively, difficult to correctly benchmark 
code. The best way is to take your actual application, give it some real 
world data to process, and time how long it takes.


-- 
Steven



More information about the Python-list mailing list