[C++-sig] Some thoughts on py3k support

Ralf W. Grosse-Kunstleve rwgk at yahoo.com
Wed Mar 18 18:44:46 CET 2009


C++ has wchar_t and std::wstring. Could these be leveraged to avoid ambiguities?
E.g. char, std::string are mapped to py3 byte objects, wchar_t and std::wstring
to py3 str objects.

(Hope this suggestion isn't totally dumb; I have very little experience using
unicode strings.)



----- Original Message ----
From: Haoyu Bai <divinekid at gmail.com>
To: Development of Python/C++ integration <cplusplus-sig at python.org>
Sent: Wednesday, March 18, 2009 7:53:25 AM
Subject: Re: [C++-sig] Some thoughts on py3k support

On Wed, Mar 18, 2009 at 7:25 AM, Rene Rivera <grafikrobot at gmail.com> wrote:
> Matthew Scouten (TT) wrote:
>>
>> I can work with whatever you come up with, but it might convenient if a
>> char* or char[] was treated as a bytes object and a std::string was
>> treated as a string. Thoughts?
>
> A char* can never be fully treated as a bytes object. You must mean a char*
> plus a size_t (or two char* iterator pointers). At which point any
> convenience you think you are getting from treating char* as bytes is gone
> as you have to introduce an intermediate type anyway to put in the "buffer"
> semantics. Hence you are better off with real buffer objects, or equivalents
> thereof. Say a std::pair<char*,char*> iterator range, or std::vector<char>,
> etc.
>

Indeed char* is usually represent a string. For raw buffer there's a
'buffer' type in Python may be suitable in this case. So we would like
to just provide a converter and just let user to specify it if a raw
buffer is required.

-- Haoyu Bai
_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig at python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig



More information about the Cplusplus-sig mailing list