Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #90760
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <cameron@cskk.homeip.net> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.005 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; '16,': 0.03; 'string': 0.09; 'subject:characters': 0.09; 'subject:string': 0.09; '"\\n")': 0.16; '(it': 0.16; '>on': 0.16; 'formatted': 0.16; 'forth.': 0.16; 'from:addr:cs': 0.16; 'from:addr:zip.com.au': 0.16; 'from:name:cameron simpson': 0.16; 'message- id:@cskk.homeip.net': 0.16; 'received:211.29': 0.16; 'received:211.29.132': 0.16; 'received:cskk.homeip.net': 0.16; 'received:homeip.net': 0.16; 'received:optusnet.com.au': 0.16; 'received:syd.optusnet.com.au': 0.16; 'simpson': 0.16; 'subject: \n ': 0.16; 'subject:remove': 0.16; 'wrote:': 0.18; 'header:User- Agent:1': 0.23; 'cheers,': 0.24; 'header:In-Reply-To:1': 0.27; 'point': 0.28; 'chris': 0.29; 'am,': 0.29; 'lines': 0.31; 'stuff': 0.32; 'comment': 0.34; 'subject:the': 0.34; "i'd": 0.34; 'subject:from': 0.34; 'really': 0.36; 'received:com.au': 0.36; 'doing': 0.36; 'charset:us-ascii': 0.36; 'list': 0.37; 'performance': 0.37; 'received:211': 0.38; 'to:addr:python-list': 0.38; 'skip:- 10': 0.38; 'to:addr:python.org': 0.39; 'details.': 0.61; 'simply': 0.61; "you're": 0.61; 'content- disposition:inline': 0.62; 'email addr:gmail.com': 0.63; 'more': 0.64; '2015': 0.84; 'end.': 0.84; 'subject:long': 0.84; 'subject:very': 0.91 |
| Date | Sun, 17 May 2015 08:41:14 +1000 |
| From | Cameron Simpson <cs@zip.com.au> |
| To | python-list@python.org |
| Subject | Re: Fastest way to remove the first x characters from a very long string |
| MIME-Version | 1.0 |
| Content-Type | text/plain; charset=us-ascii; format=flowed |
| Content-Disposition | inline |
| In-Reply-To | <8354e4ba-0a80-48a1-b2e9-6edb4b67ff36@googlegroups.com> |
| User-Agent | Mutt/1.5.23 (2014-03-12) |
| References | <8354e4ba-0a80-48a1-b2e9-6edb4b67ff36@googlegroups.com> |
| X-Optus-CM-Score | 0 |
| X-Optus-CM-Analysis | v=2.1 cv=L/MkHYj8 c=1 sm=1 tr=0 a=rgDbx50tNA2z7xLXQOoruw==:117 a=rgDbx50tNA2z7xLXQOoruw==:17 a=ZtCCktOnAAAA:8 a=PO7r1zJSAAAA:8 a=J0QyKEt1u0cA:10 a=kj9zAlcOel0A:10 a=vrnE16BAAAAA:8 a=h1PgugrvaO0A:10 a=pGLkceISAAAA:8 a=IMekcmy9rMVGAvvEN0kA:9 a=CjuIK1q_8ugA:10 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.20+ |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.87.1431817664.17265.python-list@python.org> (permalink) |
| Lines | 27 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1431817664 news.xs4all.nl 2922 [2001:888:2000:d::a6]:40651 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:90760 |
Show key headers only | View raw
On 16May2015 10:35, bruceg113355@gmail.com <bruceg113355@gmail.com> wrote:
>On Saturday, May 16, 2015 at 12:59:19 PM UTC-4, Chris Angelico wrote:
>> On Sun, May 17, 2015 at 2:22 AM, <bruceg113355@gmail.com> wrote:
>> > # Original Approach
>> > # -----------------
>> > ss = ss.split("\n")
>> > ss1 = ""
>> > for sdata in ss:
>> > ss1 = ss1 + (sdata[OFFSET:] + "\n")
>> >
>> > # Chris's Approach
>> > # ----------------
>> > lines = ss.split("\n")
>> > new_text = "\n".join(line[8:] for line in lines)
[...]
>
>Your approach more than meets my requirements.
>Data is formatted correctly and performance is simply amazing.
>OFFSET and \n are small details.
The only comment I'd make at this point is to consider if you really need a
single string at the end. Keeping it as a list of lines may be more flexible.
(It will consume more memory.) If you're doing more stuff with the string as
lines then you'd need to re-split it, and so forth.
Cheers,
Cameron Simpson <cs@zip.com.au>
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Fastest way to remove the first x characters from a very long string bruceg113355@gmail.com - 2015-05-16 06:28 -0700
Re: Fastest way to remove the first x characters from a very long string Joel Goldstick <joel.goldstick@gmail.com> - 2015-05-16 09:43 -0400
Re: Fastest way to remove the first x characters from a very long string Chris Angelico <rosuav@gmail.com> - 2015-05-16 23:45 +1000
Re: Fastest way to remove the first x characters from a very long string bruceg113355@gmail.com - 2015-05-16 07:02 -0700
Re: Fastest way to remove the first x characters from a very long string bruceg113355@gmail.com - 2015-05-16 09:22 -0700
Re: Fastest way to remove the first x characters from a very long string Ian Kelly <ian.g.kelly@gmail.com> - 2015-05-16 10:57 -0600
Re: Fastest way to remove the first x characters from a very long string Chris Angelico <rosuav@gmail.com> - 2015-05-17 02:59 +1000
Re: Fastest way to remove the first x characters from a very long string bruceg113355@gmail.com - 2015-05-16 10:35 -0700
Re: Fastest way to remove the first x characters from a very long string Cameron Simpson <cs@zip.com.au> - 2015-05-17 08:41 +1000
Re: Fastest way to remove the first x characters from a very long string Grant Edwards <invalid@invalid.invalid> - 2015-05-16 14:59 +0000
Re: Fastest way to remove the first x characters from a very long string Rustom Mody <rustompmody@gmail.com> - 2015-05-16 08:13 -0700
Re: Fastest way to remove the first x characters from a very long string bruceg113355@gmail.com - 2015-05-16 09:24 -0700
Re: Fastest way to remove the first x characters from a very long string Irmen de Jong <irmen.NOSPAM@xs4all.nl> - 2015-05-16 18:55 +0200
Re: Fastest way to remove the first x characters from a very long string Denis McMahon <denismfmcmahon@gmail.com> - 2015-05-16 23:24 +0000
csiph-web