Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #60427

Re: python for everyday tasks

Date 2013-11-25 08:11 -0700
From Michael Torrie <torriem@gmail.com>
Subject Re: python for everyday tasks
References <5737051f-26d4-4771-b4a0-d41062f1a4ef@googlegroups.com> <52900c74$0$29993$c3e8da3$5496439d@news.astraweb.com> <d41c02c1-22f4-477c-b4ad-79001f13e302@googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.3179.1385392311.18130.python-list@python.org> (permalink)

Show all headers | View raw


I only respond here, as unicode in general is an important concept that
the OP will to make sure his students understand in Python, and I don't
want you to dishonestly sow the seeds of uncertainty and doubt.

On 11/25/2013 03:12 AM, wxjmfauth@gmail.com wrote:
> Your paragraph is mixing different concepts.

On the contrary, it appears you are the one mixing the concepts, and
confusing a byte-encoding scheme with unicode.

In an ideal world, the programmer should not need to know or care about
what encoding scheme the language is using internally to store strings.
 And it does not matter whether the internal encoding scheme is endorsed
by the unicode commission or not, provided it can handle all the valid
unicode constructs.

A string is unicode.  Period.  Hence you must concern yourself with
encoding only when reading or writing a byte stream.

Inside the language itself, the encoding is irrelevant.  Ideally.  In
python 3.3+ anyway.  Of course reality is different in other languages
which is why programmers are used to worrying about things like exposing
surrogate pairs (as Javascript does), or having to tweak your algorithms
to deal with the fact that UTF-8 indexing is not O(1).  To claim that a
programmer has to concern himself with internal language encoding in
Python 3 is not only untrue, it's ingenuousness at best, given the OP's
mission.

> When it comes to save memory, utf-8 is the choice. It
> beats largely the FSR on the side of memory and on
> the side of performances.

So you would condemn everyone to use an O(n) encoding for a string when
FSR offers full unicode compliance that optimizes both speed and memory?

No, D'Aprano is correct.  Python 3.3+ indeed does unicode right.  It
offers O(1) slicing, is memory efficient, and never exposes things like
surrogate pairs.

> How and why? I suggest, you have a deeper understanding
> of unicode.

Indeed I'd say D'Aprano does have a deeper understanding of unicode.

> May I recall, it is one of the coding scheme endorsed
> by "Unicode.org" and it is intensively used. This is not
> by chance.

Yes, you keep saying this.  Have you encountered a real-world situation
where you are impacted by Python's FSR? You keep posting silly
benchmarks that prove nothing, and continue arguing, yet presumably you
are still using Python.  Why haven't you switched to Google Go or
another language that implements unicode strings in UTF-8?

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

python for everyday tasks koch.mate@gmail.com - 2013-11-22 15:59 -0800
  Re: python for everyday tasks Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-11-23 02:01 +0000
    Re: python for everyday tasks wxjmfauth@gmail.com - 2013-11-25 02:12 -0800
      Re: python for everyday tasks Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-11-25 13:33 +0000
      Re: python for everyday tasks Michael Torrie <torriem@gmail.com> - 2013-11-25 08:11 -0700
        Re: python for everyday tasks wxjmfauth@gmail.com - 2013-11-25 08:17 -0800
      Re: python for everyday tasks Chris Angelico <rosuav@gmail.com> - 2013-11-26 02:38 +1100
      Re: python for everyday tasks Ben Finney <ben+python@benfinney.id.au> - 2013-11-26 10:35 +1100
      Re: python for everyday tasks Chris Angelico <rosuav@gmail.com> - 2013-11-26 11:09 +1100
    Re: python for everyday tasks Pavel Volkov <negaipub@gmail.com> - 2013-11-27 22:05 +0400
    Re: python for everyday tasks Michael Torrie <torriem@gmail.com> - 2013-11-27 11:15 -0700
    Re: python for everyday tasks Chris Angelico <rosuav@gmail.com> - 2013-11-28 10:11 +1100
  Re: python for everyday tasks Ned Batchelder <ned@nedbatchelder.com> - 2013-11-22 18:32 -0800
  Re: python for everyday tasks Dan Stromberg <drsalists@gmail.com> - 2013-11-22 22:28 -0800
  Re: python for everyday tasks Dan Stromberg <drsalists@gmail.com> - 2013-11-22 22:36 -0800
  Re: python for everyday tasks Chris Angelico <rosuav@gmail.com> - 2013-11-23 18:25 +1100
    Re: python for everyday tasks koch.mate@gmail.com - 2013-11-23 16:54 -0800

csiph-web