Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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; '*not*': 0.07; 'string': 0.09; 'ascii': 0.09; 'character,': 0.09; 'chunk': 0.09; 'conversions': 0.09; 'immutable': 0.09; 'insertion': 0.09; 'optimizing': 0.09; 'typed': 0.09; 'python': 0.11; 'suggest': 0.14; 'wrote': 0.14; '(it': 0.16; 'added.': 0.16; 'adjacent': 0.16; 'buffer.': 0.16; 'chunks': 0.16; 'chunks.': 0.16; 'editor,': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'implies': 0.16; 'inserting': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'mutable': 0.16; 'octets': 0.16; 'received:84.93': 0.16; 'received:84.93.230': 0.16; 'unpacked': 0.16; 'wastes': 0.16; 'words.': 0.16; 'language': 0.16; 'wrote:': 0.18; 'bit': 0.19; 'split': 0.19; 'memory': 0.22; 'header:User-Agent:1': 0.23; 'char': 0.24; 'copied': 0.24; 'finally,': 0.24; 'sorry,': 0.24; 'together.': 0.24; 'second': 0.26; 'header:In-Reply-To:1': 0.27; 'idea': 0.28; 'character': 0.29; 'characters': 0.30; 'nature': 0.30; 'waste': 0.30; 'supposed': 0.32; 'checking': 0.33; 'totally': 0.33; 'copying': 0.34; 'could': 0.34; 'convert': 0.35; 'editor': 0.35; 'received:84': 0.35; 'test': 0.35; 'but': 0.35; 'joined': 0.36; 'next': 0.36; 'list': 0.37; 'somebody': 0.38; 'to:addr:python- list': 0.38; 'fact': 0.38; 'little': 0.38; 'does': 0.39; 'bad': 0.39; 'sure': 0.39; 'to:addr:python.org': 0.39; 'even': 0.60; 'new': 0.61; 'simple': 0.61; 'first': 0.61; 'email addr:gmail.com': 0.63; 'show': 0.63; 'real': 0.63; 'soon': 0.63; 'more': 0.64; 'finally': 0.65; 'charset:windows-1252': 0.65; 'header:Reply-To:1': 0.67; 'optimized': 0.68; 'reply-to:no real name:2**0': 0.71; 'characters,': 0.84; 'fast,': 0.84; 'pardon': 0.84; 'reply-to:addr:python.org': 0.84; 'usage.': 0.84 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.1 cv=RZapVTdv c=1 sm=1 tr=0 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=0Bzu9jTXAAAA:8 a=K2DDQYBT4xIA:10 a=ihvODaAuJD4A:10 a=OUOv7kDek9cA:10 a=N659UExz7-8A:10 a=EBOSESyhAAAA:8 a=8AHkEIZyAAAA:8 a=-vha-_sxYaMA:10 a=pGLkceISAAAA:8 a=WCoX0JQBvEa-IuImogQA:9 a=pILNOxqGKmIA:10 a=MSl-tDqOz04A:10 X-AUTH: mrabarnett:2500 Date: Tue, 30 Jul 2013 17:13:40 +0100 From: MRAB User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/20130620 Thunderbird/17.0.7 MIME-Version: 1.0 To: python-list@python.org Subject: Re: RE Module Performance References: <571a6dfe-fd66-42cf-92fc-8b97cbe6e9e4@googlegroups.com> <51DFDE65.5040001@Gmail.com> <4f1067f6-bc99-42ad-9166-37fb228b90e8@googlegroups.com> <51f14395$0$29971$c3e8da3$5496439d@news.astraweb.com> <51f15e03$0$29971$c3e8da3$5496439d@news.astraweb.com> <8203e802-9dc5-44c5-9547-6e1947ee224b@googlegroups.com> <43ce1b65-9d6d-47dd-b209-9a3bbafc0b8c@googlegroups.com> <51F7CFD1.1090403@rece.vub.ac.be> In-Reply-To: <51F7CFD1.1090403@rece.vub.ac.be> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: python-list@python.org 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: 52 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1375200818 news.xs4all.nl 15909 [2001:888:2000:d::a6]:43011 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:51578 On 30/07/2013 15:38, Antoon Pardon wrote: > Op 30-07-13 16:01, wxjmfauth@gmail.com schreef: >> >> I am pretty sure that once you have typed your 127504 ascii >> characters, you are very happy the buffer of your editor does not >> waste time in reencoding the buffer as soon as you enter an €, the >> 125505th char. Sorry, I wanted to say z instead of euro, just to >> show that backspacing the last char and reentering a new char >> implies twice a reencoding. > > Using a single string as an editor buffer is a bad idea in python for > the simple reason that strings are immutable. Using a single string as an editor buffer is a bad idea in _any_ language because an insertion would require all the following characters to be moved. > So adding characters would mean continuously copying the string > buffer into a new string with the next character added. Copying > 127504 characters into a new string will not make that much of a > difference whether the octets are just copied to octets or are > unpacked into 32 bit words. > >> Somebody wrote "FSR" is just an optimization. Yes, but in case of >> an editor à la FSR, this optimization take place everytime you >> enter a char. Your poor editor, in fact the FSR, is finally >> spending its time in optimizing and finally it optimizes nothing. >> (It is even worse). > > Even if you would do it this way, it would *not* take place every > time you enter a char. Once your buffer would contain a wide > character, it would just need to convert the single character that is > added after each keystroke. It would not need to convert the whole > buffer after each key stroke. > >> If you type correctly a z instead of an €, it is not necessary to >> reencode the buffer. Problem, you do you know that you do not have >> to reencode? simple just check it, and by just checking it wastes >> time to test it you have to optimized or not and hurt a little bit >> more what is supposed to be an optimization. > > Your scenario is totally unrealistic. First of all because of the > immutable nature of python strings, second because you suggest that > real time usage would result in frequent conversions which is highly > unlikely. > What you would have is a list of mutable chunks. Inserting into a chunk would be fast, and a chunk would be split if it's already full. Also, small adjacent chunks would be joined together. Finally, a chunk could use FSR to reduce memory usage.