Re: (silly?) speed comparisons

2008-07-09 Thread Peter Otten
mk wrote: Now C++ version took over twice the time to execute in comparison to Python time! Am I comparing apples to oranges? Indeed. Where in Python you're passing references your C++ code produces copies of the vector. For starters you can change the function signature to void

Re: (silly?) speed comparisons

2008-07-09 Thread mk
Rajanikanth Jammalamadaka wrote: Try using a list instead of a vector for the C++ version. Well, it's even slower: $ time slice4 real0m4.500s user0m0.015s sys 0m0.015s Time of execution of vector version (using reference to a vector): $ time slice2 real0m2.420s user

Re: (silly?) speed comparisons

2008-07-09 Thread Maric Michaud
Le Wednesday 09 July 2008 12:35:10 mk, vous avez écrit : vectorstring move_slice(vectorstring vec, int start, int stop, int dest) I guess the point is to make a vector of referene to string if you don't want to copy string objects all around but just a word for an address each time. The

Re: (silly?) speed comparisons

2008-07-09 Thread mk
Maric Michaud wrote: Le Wednesday 09 July 2008 12:35:10 mk, vous avez écrit : vectorstring move_slice(vectorstring vec, int start, int stop, int dest) I guess the point is to make a vector of referene to string if you don't want to copy string objects all around but just a word for an

Re: (silly?) speed comparisons

2008-07-09 Thread mk
P.S. Java 1.6 rocks - I wrote equivalent version using ArrayList and it executed in 0.7s. -- http://mail.python.org/mailman/listinfo/python-list

(silly?) speed comparisons

2008-07-08 Thread mk
Out of curiosity I decided to make some speed comparisons of the same algorithm in Python and C++. Moving slices of lists of strings around seemed like a good test case. Python code: def move_slice(list_arg, start, stop, dest): frag = list_arg[start:stop] if dest stop:

Re: (silly?) speed comparisons

2008-07-08 Thread Rajanikanth Jammalamadaka
Try using a list instead of a vector for the C++ version. Raj On Tue, Jul 8, 2008 at 3:06 PM, mk [EMAIL PROTECTED] wrote: Out of curiosity I decided to make some speed comparisons of the same algorithm in Python and C++. Moving slices of lists of strings around seemed like a good test case.

Re: (silly?) speed comparisons

2008-07-08 Thread Terry Reedy
mk wrote: Out of curiosity I decided to make some speed comparisons of the same algorithm in Python and C++. Moving slices of lists of strings around seemed like a good test case. If you use Python to, in effect, call well-written C functions, and most of the computation time is spent in