[Numpy-discussion] A one-byte string dtype?

Charles R Harris charlesr.harris at gmail.com
Mon Jan 20 15:34:56 EST 2014


On Mon, Jan 20, 2014 at 11:40 AM, Oscar Benjamin <oscar.j.benjamin at gmail.com
> wrote:

>
> On Jan 20, 2014 5:21 PM, "Charles R Harris" <charlesr.harris at gmail.com>
> wrote:
> > On Mon, Jan 20, 2014 at 10:12 AM, Aldcroft, Thomas <
> aldcroft at head.cfa.harvard.edu> wrote:
> >> On Mon, Jan 20, 2014 at 10:40 AM, Oscar Benjamin <
> oscar.j.benjamin at gmail.com> wrote:
> >>> On Mon, Jan 20, 2014 at 10:00:55AM -0500, Aldcroft, Thomas wrote:
> >>> > On Mon, Jan 20, 2014 at 5:11 AM, Oscar Benjamin
> >>>
> >>> And why are you needing to write .decode('ascii') everywhere?
> >>
> >> >>> print("The first value is {}".format(bytestring_array[0]))
> >>
> >> On Python 2 this gives "The first value is string_value", while on
> Python 3 this gives "The first value is b'string_value'".
> >
> > As Nathaniel has mentioned, this is a known problem with Python 3 and
> the developers are trying to come up with a solution. Python 3.4 solves
> some existing problems, but this one remains. It's not just numpy here,
> it's that python itself needs to provide some help.
>
> If you think that anything in core Python will change so that you can mix
> text and bytes as above then I think you are very much mistaken. If you're
> referring to PEP 460/461 then you have misunderstood the purpose of those
> PEPs. The authors and reviewers will carefully ensure that nothing changes
> to make the above work the way that it did in 2.x.
>

I think we may want something like PEP
393<http://www.python.org/dev/peps/pep-0393/>.
The S datatype may be the wrong place to look, we might want a modification
of U instead so as to transparently get the benefit of python strings.

Chuck

>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20140120/86c20aa7/attachment.html>


More information about the NumPy-Discussion mailing list