Re: [Cython] Odd behavior with std::string and .decode()

2012-07-19 Thread Stefan Behnel
Stefan Behnel, 06.07.2012 06:48: > One thing I would generally suggest is to do this: > > descr = self._this.get_description() > return descr.data()[:descr.size()].decode('utf-8') > > Avoids the call to strlen() by explicitly slicing the pointer. Also avoids > needing to make sure the C s

Re: [Cython] Odd behavior with std::string and .decode()

2012-07-06 Thread Stefan Behnel
Barry Warsaw, 06.07.2012 16:21: > Thanks for the follow up Stefan, > > On Jul 06, 2012, at 06:48 AM, Stefan Behnel wrote: > >> This is very weird behaviour indeed. I wouldn't know why that should >> happen. What "return as_bytes.decode('utf-8')" does is that is calls >> strlen() to see how long t

Re: [Cython] Odd behavior with std::string and .decode()

2012-07-06 Thread Barry Warsaw
Thanks for the follow up Stefan, On Jul 06, 2012, at 06:48 AM, Stefan Behnel wrote: >This is very weird behaviour indeed. I wouldn't know why that should >happen. What "return as_bytes.decode('utf-8')" does is that is calls >strlen() to see how long the string is, then it calls the UTF-8 decode >

Re: [Cython] Odd behavior with std::string and .decode()

2012-07-05 Thread Stefan Behnel
Hi Barry, Barry Warsaw, 06.07.2012 00:29: > I'm currently exploring using Cython to provide new Python 3 bindings for > Xapian. I'm pretty much a Cython n00b but the documentation is great, and I > was able to pretty quickly get something really simple working. I'm using > Cython 0.15 on Ubuntu