From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-65-14.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.6 Path: eternal-september.org!reader02.eternal-september.org!border1.nntp.dca1.giganews.com!nntp.giganews.com!buffer1.nntp.dca1.giganews.com!news.giganews.com.POSTED!not-for-mail NNTP-Posting-Date: Sat, 09 Apr 2022 11:46:04 -0500 From: Dennis Lee Bieber Newsgroups: comp.lang.ada Subject: Re: Ada and Unicode Date: Sat, 09 Apr 2022 12:46:04 -0400 Organization: IISS Elusive Unicorn Message-ID: References: <86mttuk5f0.fsf@stephe-leake.org> <62515f7a$0$25324$426a74cc@news.free.fr> User-Agent: ForteAgent/8.00.32.1272 X-No-Archive: yes MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Usenet-Provider: http://www.giganews.com X-Trace: sv3-RNe4bGfTwIijB1l4maREDzfVEkoEaCtcJCxp/mlK4x+uNiOnfLQVwL9dYdqsn38iwwhUvwOyHoE3bZg!r/3FUQYqMgj25EvnF0b9Fj810sGTITRUrr38MWzhV9f6pBXCD3l+RpSyZd4K9MEUKPKs7qei X-Complaints-To: abuse@giganews.com X-DMCA-Notifications: http://www.giganews.com/info/dmca.html X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 2645 Xref: reader02.eternal-september.org comp.lang.ada:63725 List-Id: On Sat, 9 Apr 2022 12:27:04 +0200, DrPi <314@drpi.fr> declaimed the following: > >In Python-3, a string is a character(glyph ?) array. The internal >representation is hidden to the programmer. > >On the Ada side, I've still not understood how to correctly deal with >all this stuff. One thing to take into account is that Python strings are immutable. Changing the contents of a string requires constructing a new string from parts that incorporate the change. That allows for the second aspect -- even if not visible to a programmer, Python (3) strings are not a fixed representation: If all characters in the string fit in the 8-bit UTF range, that string is stored using one byte per character. If any character uses a 16-bit UTF representation, the entire string is stored as 16-bit characters (and similar for 32-bit UTF points). Thus, indexing into the string is still fast -- just needing to scale the index by the character width of the entire string. -- Wulfraed Dennis Lee Bieber AF6VN wlfraed@ix.netcom.com http://wlfraed.microdiversity.freeddns.org/