Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'matches': 0.07; 'utf-8': 0.07; '32-bit': 0.09; 'here?': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:Why': 0.09; 'question.': 0.14; 'character).': 0.16; 'encodings': 0.16; 'mutable': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-ipconnect.de': 0.16; 'unicode,': 0.16; 'wrote:': 0.18; 'bit': 0.19; 'module': 0.19; 'creating': 0.23; 'header:User-Agent:1': 0.23; 'bytes': 0.24; 'unicode': 0.24; 'pass': 0.26; 'header:X-Complaints-To:1': 0.27; 'array': 0.29; 'character': 0.29; "doesn't": 0.30; 'work.': 0.31; "d'aprano": 0.31; 'option.': 0.31; 'steven': 0.31; 'fri,': 0.33; 'guess': 0.33; 'could': 0.34; 'something': 0.35; 'subject:?': 0.36; 'searching': 0.37; 'two': 0.37; 'to:addr :python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'helps': 0.61; 'new': 0.61; 'email addr:gmail.com': 0.63; 'filling': 0.78; '2015': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Peter Otten <__peter__@web.de> Subject: Re: Why is array.array('u') deprecated? Date: Fri, 08 May 2015 13:35:30 +0200 Organization: None References: <80167ebf-c5ee-4699-89ca-ef544fe3decc@googlegroups.com> <554c8ff2$0$12990$c3e8da3$5496439d@news.astraweb.com> <93aaa9cd-5d30-44db-9324-4fffe292e9e4@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8Bit X-Gmane-NNTP-Posting-Host: p57bd82d4.dip0.t-ipconnect.de User-Agent: KNode/4.13.3 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 30 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1431084939 news.xs4all.nl 2825 [2001:888:2000:d::a6]:36828 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:90148 jonathan.slenders@gmail.com wrote: > Le vendredi 8 mai 2015 12:29:15 UTC+2, Steven D'Aprano a écrit : >> On Fri, 8 May 2015 07:14 pm, jonathan.slenders wrote: >> >> > Why is array.array('u') deprecated? >> > >> > Will we get an alternative for a character array or mutable unicode >> > string? >> >> >> Good question. >> >> Of the three main encodings for Unicode, two are variable-width: >> >> * UTF-8 uses 1-4 bytes per character >> * UTF-16 uses 2 or 4 bytes per character >> >> while UTF-32 is fixed-width (4 bytes per character). So you could try >> faking it with a 32-bit array and filling it with >> string.encode('utf-32'). > > > I guess that doesn't work. I need to have something that I can pass to the > re module for searching through it. Creating new strings all the time is > no option. (Think about gigabyte strings.) Can you expand a bit on how array("u") helps here? Are the matches in the gigabyte range?