Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #106738 > unrolled thread

Re: how to convert code that uses cmp to python3

Started byChris Angelico <rosuav@gmail.com>
First post2016-04-10 01:31 +1000
Last post2016-04-10 01:31 +1000
Articles 1 — 1 participant

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.


Contents

  Re: how to convert code that uses cmp to python3 Chris Angelico <rosuav@gmail.com> - 2016-04-10 01:31 +1000

#106738 — Re: how to convert code that uses cmp to python3

FromChris Angelico <rosuav@gmail.com>
Date2016-04-10 01:31 +1000
SubjectRe: how to convert code that uses cmp to python3
Message-ID<mailman.123.1460215898.2253.python-list@python.org>
On Sun, Apr 10, 2016 at 1:24 AM, Antoon Pardon
<antoon.pardon@rece.vub.ac.be> wrote:
> Op 09-04-16 om 16:41 schreef Chris Angelico:
>
>>
>> In this case, you're likely to end up with large branches of your tree
>> that have the same prefix. (And if you don't, your iterations are all
>> going to end early anyway, so the comparison is cheap.) A data
>> structure that takes this into account will out-perform the naive
>> comparison model every time. In fact, a simple dict will probably
>> out-perform your tree;
>
> So? I need a structure that can easily give me an answer to the
> following: Given key1 and key2 what are the the keys between them
> with their corresponding values. As long as a dict can't provide
> me with that answer, it doesn't matter that it will out perform
> lookups in my trees.

Ah, okay. You can probably still take advantage of the other thing I
mentioned, which was structuring your tree such that it's aware of the
common prefixes, even if you can't go for O(1) hashing. That would
drastically reduce the number of comparisons you have to do.

ChrisA

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web