can't sort

andrew cooke andrew at acooke.org
Mon May 26 21:31:57 EDT 2003


"Anders J. Munch" <andersjm at dancontrol.dk> writes:
> This particular code.  There's some talk though about switching to
> less-than predicates instead of -1,0,1 compares in future Pythons, so
> I'd have take that into account before nominating anything my final
> candidate.

are you following python-dev?  i thought something like that was
squashed fairly recently (koenig or ewing made the suggestion, and it
looked like guido didn't understand it, but then it appeared he did,
but then he squashed the idea anyway, iirc...)

> I suppose I should write a PEP.  Or are simple library additions below
> the PEP radar?

[disclaimer - i read python-dev from time to time, but doubt i've ever
posted there, so this is pure uninformed speculation]

if i were you i'd post to python-dev and ask (although it's probably a
bad sign that tim peters hasn't posted on this thread already), but i
get the impression that timing is everything there.  maybe you want to
wait until there's a heady surge of new feature accepting (last time i
looked they were more concerned about releasing the next maintenance
version).

i'm not sure calling it a "functional" sort (not claiming that you
did, i think it was someone else) is a good idea - probably best to
avoid the f word :o)

> cmfunc+project doesn't give you the speed gains of the DSU, so you may
> as well integrate the projection into cmpfunc.  Still, for
> completeness, and for those rare cases where the projection function
> itself is expensive, I guess the restriction should be lifted so you
> can use them together.

duh!  of course.  i didn't think of them as (possibly) equivalent.
you're right, but the interface doesn't make it obvious - you can
supply two functions and one will be silently ignored.  so either the
interface has to change (i can't think of anything nicer), or you need
to implement this anyway.

hmm.  maybe there's an interface that plays on the two being
equivalent - you could view the difference (ignoring stability) as
caching the projection function in one case, but not in the other.  so
rather than accept two different functions, could you take a single
function and a flag that describes caching behaviour?  i guess not,
because while it's easy to push the projection into the comparison, i
don't see how to pull the comparison into the projection (i have a
strange feeling that you could somehow manage this with lazy
semantics, but then python doesn't have that anyway and i'm drifting
into silly speculation... :o).

good luck,
andrew

ps is the dsu speed advantage really significant?  i normally ignore
log(n) factors (am i admitting to some terrible misdemeanour?!) as not
being worth the bother...

-- 
http://www.acooke.org






More information about the Python-list mailing list