Re: [Cython] Automatic C++ conversions

2012-07-02 Thread Robert Bradshaw
On Mon, Jul 2, 2012 at 5:49 AM, Sturla Molden wrote: > On 30.06.2012 01:06, Stefan Behnel wrote: > >>> std::string<=>  bytes >>> std::map<=>  dict >>> iterable =>  std::vector =>  list >>> iterable =>  std::list =>  list >>> iterable =>  std::set =>  set >>> 2-iterable =>  std::pair =>  2-tuple >>

Re: [Cython] Automatic C++ conversions

2012-07-02 Thread Sturla Molden
On 02.07.2012 14:49, Sturla Molden wrote: I think (in C++11) std::unordered_set and std::unordered_map should be used instead. They are hash-based with O(1) lookup. std::set and std::map are binary search threes with average O(log n) lookup and worst-case O(n**2). Sorry typo, that should be w

Re: [Cython] Automatic C++ conversions

2012-07-02 Thread Sturla Molden
On 30.06.2012 01:06, Stefan Behnel wrote: std::string<=> bytes std::map<=> dict iterable => std::vector => list iterable => std::list => list iterable => std::set => set 2-iterable => std::pair => 2-tuple Very cool. I think (in C++11) std::unordered_set and std::unordered_map shoul

Re: [Cython] Automatic C++ conversions

2012-06-29 Thread Robert Bradshaw
On Fri, Jun 29, 2012 at 4:06 PM, Stefan Behnel wrote: > Robert Bradshaw, 30.06.2012 00:38: >> I implemented >> >> std::string <=> bytes >> std::map <=> dict >> iterable => std::vector => list >> iterable => std::list => list >> iterable => std::set => set >> 2-iterable => std::pair => 2-tuple > >

Re: [Cython] Automatic C++ conversions

2012-06-29 Thread Stefan Behnel
Robert Bradshaw, 30.06.2012 00:38: > I implemented > > std::string <=> bytes > std::map <=> dict > iterable => std::vector => list > iterable => std::list => list > iterable => std::set => set > 2-iterable => std::pair => 2-tuple Very cool. >> What about allowing list() etc.? As long as the ite

Re: [Cython] Automatic C++ conversions

2012-06-29 Thread Robert Bradshaw
On Thu, Jun 28, 2012 at 5:10 AM, Stefan Behnel wrote: > Robert Bradshaw, 28.06.2012 12:07: >> On Thu, Jun 28, 2012 at 2:54 AM, Stefan Behnel wrote: >>> Robert Bradshaw, 28.06.2012 10:59: I've been looking how painful it is to constantly convert between Python objects and string in C++. >

Re: [Cython] Automatic C++ conversions

2012-06-28 Thread Stefan Behnel
Robert Bradshaw, 28.06.2012 12:07: > On Thu, Jun 28, 2012 at 2:54 AM, Stefan Behnel wrote: >> Robert Bradshaw, 28.06.2012 10:59: >>> I've been looking how painful it is to constantly convert between >>> Python objects and string in C++. >> >> You mean std::string (as I think it's called)? Can't we

Re: [Cython] Automatic C++ conversions

2012-06-28 Thread Robert Bradshaw
On Thu, Jun 28, 2012 at 2:54 AM, Stefan Behnel wrote: > Robert Bradshaw, 28.06.2012 10:59: >> I've been looking how painful it is to constantly convert between >> Python objects and string in C++. > > You mean std::string (as I think it's called)? Can't we just special case > that in the same way

Re: [Cython] Automatic C++ conversions

2012-06-28 Thread Stefan Behnel
Robert Bradshaw, 28.06.2012 10:59: > I've been looking how painful it is to constantly convert between > Python objects and string in C++. You mean std::string (as I think it's called)? Can't we just special case that in the same way that we special case char* and friends? Basically just one type

[Cython] Automatic C++ conversions

2012-06-28 Thread Robert Bradshaw
I've been looking how painful it is to constantly convert between Python objects and string in C++. Yes, it's easy to write a utility, but this should be as natural (if not more so, as the length is explicit) than bytes <-> char*. Several other of the libcpp classes (vector, map) have natural Pytho