Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #106677 > unrolled thread
| Started by | Antoon Pardon <antoon.pardon@rece.vub.ac.be> |
|---|---|
| First post | 2016-04-08 15:31 +0200 |
| Last post | 2016-04-08 16:22 +0200 |
| Articles | 3 — 2 participants |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: how to convert code that uses cmp to python3 Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2016-04-08 15:31 +0200
Re: how to convert code that uses cmp to python3 Marko Rauhamaa <marko@pacujo.net> - 2016-04-08 16:52 +0300
Re: how to convert code that uses cmp to python3 Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2016-04-08 16:22 +0200
| From | Antoon Pardon <antoon.pardon@rece.vub.ac.be> |
|---|---|
| Date | 2016-04-08 15:31 +0200 |
| Subject | Re: how to convert code that uses cmp to python3 |
| Message-ID | <mailman.81.1460122331.2253.python-list@python.org> |
Op 08-04-16 om 09:47 schreef Ben Finney:
> Antoon Pardon <antoon.pardon@rece.vub.ac.be> writes:
>
>> But it was already working and optimized. The python3 approach forces
>> me to make changes to working code and make the performance worse.
> Yes, changing from Python 2 to Python 3 entails changing working code,
> and entails different implementations for some things.
>
> As for worse performance, that is something you can objectively measure.
> What is the size of the performance reduction you have objectively
> measured from this change?
Well having a list of 1000 Sequence like object. Each sequence
containing between 1 and 100 numbers. Comparing each sequence
to each other a 100 times. I get the following results.
Doing it as follows:
seq1 < seq2
seq2 < seq1
takes about 110 seconds.
Doing it like this:
delta = cmp(seq1, seq2)
delta < 0
delta > 0
takes about 50 seconds.
Comparing was done by just iterating over the two sequences and
the first time both numbers were not the same, returning the difference
of the numbers
Granted, this test just lifted the comparison code from the module.
What was interesting was that the worst case in python3 was comparable
to the better case in python2.
--
Antoon.
[toc] | [next] | [standalone]
| From | Marko Rauhamaa <marko@pacujo.net> |
|---|---|
| Date | 2016-04-08 16:52 +0300 |
| Message-ID | <87bn5kfbsq.fsf@elektro.pacujo.net> |
| In reply to | #106677 |
Antoon Pardon <antoon.pardon@rece.vub.ac.be>: > Well having a list of 1000 Sequence like object. Each sequence > containing between 1 and 100 numbers. Comparing each sequence > to each other a 100 times. I get the following results. > > Doing it as follows: > seq1 < seq2 > seq2 < seq1 > > takes about 110 seconds. > > Doing it like this: > delta = cmp(seq1, seq2) > delta < 0 > delta > 0 > > takes about 50 seconds. Looks like a completely artificial scenario. Marko
[toc] | [prev] | [next] | [standalone]
| From | Antoon Pardon <antoon.pardon@rece.vub.ac.be> |
|---|---|
| Date | 2016-04-08 16:22 +0200 |
| Message-ID | <mailman.87.1460125333.2253.python-list@python.org> |
| In reply to | #106680 |
Op 08-04-16 om 15:52 schreef Marko Rauhamaa: > Antoon Pardon <antoon.pardon@rece.vub.ac.be>: > >> Well having a list of 1000 Sequence like object. Each sequence >> containing between 1 and 100 numbers. Comparing each sequence >> to each other a 100 times. I get the following results. >> >> Doing it as follows: >> seq1 < seq2 >> seq2 < seq1 >> >> takes about 110 seconds. >> >> Doing it like this: >> delta = cmp(seq1, seq2) >> delta < 0 >> delta > 0 >> >> takes about 50 seconds. > Looks like a completely artificial scenario. > It is the code I run when I traverse a tree and decide either to go left, right or have found the node I am looking for. And yes I have worked with keys like that. -- Antoon
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web