Re: Details about pythons set implementation

2008-01-19 Thread Albert van der Horst
In article <[EMAIL PROTECTED]>, bukzor <[EMAIL PROTECTED]> wrote: >On Jan 4, 2:15 pm, Steven D'Aprano <[EMAIL PROTECTED] >cybersource.com.au> wrote: >> On Fri, 04 Jan 2008 09:29:50 -0800, bukzor wrote: >> > Why cant you implement < for complex numbers? Maybe I'm being naive, but >> > isn't this th

Re: Details about pythons set implementation

2008-01-05 Thread bearophileHUGS
Sion Arrowsmith: > Because ... how to be polite about this? No, I can't. std::set is > crap. The implementation is a sorted sequence What about using hash_map instead? You can use it with GCC too (but you have to use a trick if you want to use string keys). Bye, bearophile -- http://mail.python.

Re: Details about pythons set implementation

2008-01-05 Thread bukzor
On Jan 4, 2:15 pm, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Fri, 04 Jan 2008 09:29:50 -0800, bukzor wrote: > > Why cant you implement < for complex numbers? Maybe I'm being naive, but > > isn't this the normal definition? > > a + bi < c + di iff sqrt(a**2 + b**2) < sqr

Re: Details about pythons set implementation

2008-01-05 Thread r . grimm
On Jan 4, 6:08 pm, Sion Arrowsmith <[EMAIL PROTECTED]> wrote: > Hrvoje Niksic <[EMAIL PROTECTED]> wrote: > > >BTW if you're using C++, why not simply use std::set? > > Because ... how to be polite about this? No, I can't. std::set is > crap. The implementation is a sorted sequence -- if you're luc

Re: Details about pythons set implementation

2008-01-04 Thread Arnaud Delobelle
On Jan 4, 10:15 pm, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Fri, 04 Jan 2008 09:29:50 -0800, bukzor wrote: > > Why cant you implement < for complex numbers? Maybe I'm being naive, but > > isn't this the normal definition? > >     a + bi < c + di iff sqrt(a**2 + b**2) < sq

Re: Details about pythons set implementation

2008-01-04 Thread Steven D'Aprano
On Fri, 04 Jan 2008 09:29:50 -0800, bukzor wrote: > Why cant you implement < for complex numbers? Maybe I'm being naive, but > isn't this the normal definition? > a + bi < c + di iff sqrt(a**2 + b**2) < sqrt(c**2, d**2) No, it is not. Ordered comparisons are not defined for complex numbers.

Re: Details about pythons set implementation

2008-01-04 Thread Piet van Oostrum
> bukzor <[EMAIL PROTECTED]> (B) wrote: >B> Why cant you implement < for complex numbers? Maybe I'm being naive, >B> but isn't this the normal definition? >B> a + bi < c + di iff sqrt(a**2 + b**2) < sqrt(c**2, d**2) There doesn't exist a `normal' definition of < for the complex numbers. F

Re: Details about pythons set implementation

2008-01-04 Thread Diez B. Roggisch
bukzor schrieb: > On Jan 4, 9:08 am, Sion Arrowsmith <[EMAIL PROTECTED]> > wrote: >> Hrvoje Niksic <[EMAIL PROTECTED]> wrote: >> >>> BTW if you're using C++, why not simply use std::set? >> Because ... how to be polite about this? No, I can't. std::set is >> crap. The implementation is a sorted se

Re: Details about pythons set implementation

2008-01-04 Thread Arnaud Delobelle
On Jan 4, 5:08 pm, Sion Arrowsmith <[EMAIL PROTECTED]> wrote: [...] > But the real killer is that requirement for a std::set is that > T::operator< exists. Which means, for instance, that you can't > have a set of complex numbers This is really OT but IIRC, std::set is actually std::set< T, st

Re: Details about pythons set implementation

2008-01-04 Thread bukzor
On Jan 4, 9:08 am, Sion Arrowsmith <[EMAIL PROTECTED]> wrote: > Hrvoje Niksic <[EMAIL PROTECTED]> wrote: > > >BTW if you're using C++, why not simply use std::set? > > Because ... how to be polite about this? No, I can't. std::set is > crap. The implementation is a sorted sequence -- if you're luc

Re: Details about pythons set implementation

2008-01-04 Thread Sion Arrowsmith
Hrvoje Niksic <[EMAIL PROTECTED]> wrote: >BTW if you're using C++, why not simply use std::set? Because ... how to be polite about this? No, I can't. std::set is crap. The implementation is a sorted sequence -- if you're lucky, this is a heap or a C array, and you've got O(log n) performance. But

Re: Details about pythons set implementation

2008-01-04 Thread Hrvoje Niksic
Achim Domma <[EMAIL PROTECTED]> writes: > I'm interested in details about how sets are implemented in python. > They seem to be quite fast and I found some remarks who state, that > the implementation is highly optimized. I need to implemented sets > in C/C++ and need a starting point on how to do

Re: Details about pythons set implementation

2008-01-04 Thread Neil Cerutti
On Jan 4, 2008 9:54 AM, Achim Domma <[EMAIL PROTECTED]> wrote: > Hi, > > I'm interested in details about how sets are implemented in python. > They seem to be quite fast and I found some remarks who state, that > the implementation is highly optimized. I need to implemented sets in > C/C++ and nee

Details about pythons set implementation

2008-01-04 Thread Achim Domma
Hi, I'm interested in details about how sets are implemented in python. They seem to be quite fast and I found some remarks who state, that the implementation is highly optimized. I need to implemented sets in C/C++ and need a starting point on how to do it right. Could somebody give me a starting