Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #36205
| 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!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <ian.g.kelly@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'python,': 0.02; 'modified': 0.05; 'socket': 0.05; 'c++,': 0.07; 'lines.': 0.07; 'parser': 0.07; 'parsing': 0.07; 'rewrite': 0.07; 'subject:help': 0.07; 'python': 0.09; '(actually': 0.09; 'expectation': 0.09; 'splitting': 0.09; 'subject:skip:m 10': 0.09; 'subject:string': 0.09; 'contribute': 0.10; 'language': 0.14; 'sat,': 0.15; '"good': 0.16; 'anyway).': 0.16; 'measured': 0.16; 'module).': 0.16; 'pythonic': 0.16; 'splits': 0.16; 'using,': 0.16; 'string': 0.17; 'wrote:': 0.17; 'byte': 0.17; 'bytes': 0.17; 'jan': 0.18; 'code,': 0.18; 'input': 0.18; 'module': 0.19; 'written': 0.20; 'parse': 0.22; 'machine': 0.24; 'header:In-Reply- To:1': 0.25; 'wrote': 0.26; 'am,': 0.27; 'implemented': 0.27; 'c++': 0.27; 'message-id:@mail.gmail.com': 0.27; 'went': 0.28; 'all.': 0.28; 'chris': 0.28; 'fine': 0.28; '(since': 0.29; 'ansi': 0.29; 'though.': 0.29; 'probably': 0.29; 'code': 0.31; '(and': 0.32; 'point,': 0.33; 'handle': 0.33; 'to:addr:python-list': 0.33; 'version': 0.34; "can't": 0.34; 'received:google.com': 0.34; 'text': 0.34; 'faster': 0.35; 'machines': 0.35; 'protocol': 0.35; 'received:209.85.220': 0.35; 'subject:?': 0.35; 'similar': 0.35; 'received:209.85': 0.35; 'there': 0.35; 'but': 0.36; "wasn't": 0.36; "didn't": 0.36; 'client': 0.36; 'test': 0.36; 'too': 0.36; 'level': 0.37; 'two': 0.37; 'uses': 0.37; 'being': 0.37; 'received:209': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'easier': 0.38; 'performance': 0.39; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'your': 0.60; 'most': 0.61; 'high': 0.61; 'subject:Need': 0.61; 'between': 0.63; 'different': 0.63; 'more': 0.63; 'subject:. ': 0.66; 'miss': 0.75; '2013': 0.84; 'divide': 0.84; 'running,': 0.84; 'to:name:python': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=DqhpsK5J5weXD2Ggb9oynNgtYxoh/N0LFbzI3RLS7Xo=; b=cUdgFe2RrPZtRiuOrMqcoD3YCel489xZ5sKDPeJn98wtMekXxoju7wyS2t5REf46B8 EkddaNT6Kjh7Xn1xbtLHVicU+2GgLCLz5K0mmy02g7yNSEyNhvfso4Ugpp74LwjSHO3p /+NdpNgIT5u0dhuQN5duyEqwUjoNBDcGTuLBVrsF71W13HYZ8K7DGj/MQ/Hp+eYXWA8T i5e+hDm/xqfhMRjMkjwdi25LjP05H2RbvGfIeg3yoo6uOerLumMfEFoBsA6U7/8X7SIu kEiIMH8SQMsSqiIUjQkLrNyIDlsotJBhTfqBT+r/1LzJmgIGC2rGn8P4nSt5u100A+eP TuGQ== |
| MIME-Version | 1.0 |
| In-Reply-To | <CAPTjJmquvQ-=L=HPfkKEkN5h6J2FRrHOeTDqMMjAc7SbtpaTpQ@mail.gmail.com> |
| References | <e480480d-f3b4-4491-969c-7d1843bf9e33@googlegroups.com> <mailman.109.1357378077.2939.python-list@python.org> <roy-564DD8.09304505012013@news.panix.com> <mailman.120.1357397255.2939.python-list@python.org> <roy-00F3AB.10030605012013@news.panix.com> <mailman.121.1357398573.2939.python-list@python.org> <roy-088CDF.10385405012013@news.panix.com> <CAPTjJmquvQ-=L=HPfkKEkN5h6J2FRrHOeTDqMMjAc7SbtpaTpQ@mail.gmail.com> |
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | Sat, 5 Jan 2013 13:04:56 -0700 |
| Subject | Re: Need a specific sort of string modification. Can someone help? |
| To | Python <python-list@python.org> |
| Content-Type | text/plain; charset=ISO-8859-1 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://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 | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.141.1357416824.2939.python-list@python.org> (permalink) |
| Lines | 27 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1357416824 news.xs4all.nl 6870 [2001:888:2000:d::a6]:52973 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:36205 |
Show key headers only | View raw
On Sat, Jan 5, 2013 at 8:57 AM, Chris Angelico <rosuav@gmail.com> wrote: > You miss my point, though. I went for simple Pythonic code, and never > measured its performance, on the expectation that it's "good enough". > Written in C, the state machine is probably WAY faster than splitting > and then iterating. My C++ MUD client uses code similar to that to > parse TELNET and ANSI codes from a stream of bytes in a socket (and > one of its "states" is that there's no more data available, so wait on > the socket); the rewrite in a high level language divides the string > on "\xFF" for TELNET and "\x1B" for ANSI, working them separately, and > then afterward splits on "\n" to divide into lines. The code's much > less convoluted, it's easier to test different parts (because I can > simply call the ANSI parser with a block of text), and on a modern > computer, you can't see the performance difference (since you spend > most of your time waiting for socket data anyway). Anecdotally and somewhat off-topic, when I wrote my own MUD client in Python, I implemented both TELNET and ANSI parsing in Python using a state machine processing one byte at a time (actually two state machines - one at the protocol layer and one at the client layer; the telnet module is a modified version of the twisted.conch.telnet module). I was worried that the processing would be too slow in Python. When I got it running, it turned out that there was a noticeable lag between input being received and displayed. But when I profiled the issue it actually turned out that the rich text control I was using, which was written in C++, wasn't able to handle a large buffer gracefully. The parsing code in Python did just fine and didn't contribute to the lag issue at all.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Need a specific sort of string modification. Can someone help? Sia <hossein.asgharian@gmail.com> - 2013-01-05 00:35 -0800
Re: Need a specific sort of string modification. Can someone help? Frank Millman <frank@chagford.com> - 2013-01-05 11:15 +0200
Re: Need a specific sort of string modification. Can someone help? Chris Angelico <rosuav@gmail.com> - 2013-01-05 20:27 +1100
Re: Need a specific sort of string modification. Can someone help? Roy Smith <roy@panix.com> - 2013-01-05 09:30 -0500
Re: Need a specific sort of string modification. Can someone help? Chris Angelico <rosuav@gmail.com> - 2013-01-06 01:47 +1100
Re: Need a specific sort of string modification. Can someone help? Roy Smith <roy@panix.com> - 2013-01-05 10:03 -0500
Re: Need a specific sort of string modification. Can someone help? Chris Angelico <rosuav@gmail.com> - 2013-01-06 02:09 +1100
Re: Need a specific sort of string modification. Can someone help? Roy Smith <roy@panix.com> - 2013-01-05 10:38 -0500
Re: Need a specific sort of string modification. Can someone help? Chris Angelico <rosuav@gmail.com> - 2013-01-06 02:57 +1100
Re: Need a specific sort of string modification. Can someone help? Ian Kelly <ian.g.kelly@gmail.com> - 2013-01-05 13:04 -0700
Re: Need a specific sort of string modification. Can someone help? Chris Angelico <rosuav@gmail.com> - 2013-01-06 07:32 +1100
Re: Need a specific sort of string modification. Can someone help? Roy Smith <roy@panix.com> - 2013-01-05 15:47 -0500
Re: Need a specific sort of string modification. Can someone help? Roy Smith <roy@panix.com> - 2013-01-06 12:28 -0500
Re: Need a specific sort of string modification. Can someone help? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-01-06 23:19 +0000
Re: Need a specific sort of string modification. Can someone help? Roy Smith <roy@panix.com> - 2013-01-05 09:12 -0500
Re: Need a specific sort of string modification. Can someone help? Tim Chase <python.list@tim.thechases.com> - 2013-01-05 11:24 -0600
Re: Need a specific sort of string modification. Can someone help? Tim Chase <python.list@tim.thechases.com> - 2013-01-05 12:49 -0600
Re: Need a specific sort of string modification. Can someone help? Mitya Sirenef <msirenef@lightbird.net> - 2013-01-06 01:32 -0500
Re: Need a specific sort of string modification. Can someone help? Mitya Sirenef <msirenef@lightbird.net> - 2013-01-06 14:53 -0500
Re: Need a specific sort of string modification. Can someone help? Nick Mellor <thebalancepro@gmail.com> - 2013-01-06 18:48 -0800
Re: Need a specific sort of string modification. Can someone help? Nick Mellor <thebalancepro@gmail.com> - 2013-01-06 19:40 -0800
Re: Need a specific sort of string modification. Can someone help? Nick Mellor <thebalancepro@gmail.com> - 2013-01-06 21:28 -0800
Re: Need a specific sort of string modification. Can someone help? Nick Mellor <thebalancepro@gmail.com> - 2013-01-06 21:30 -0800
Re: Need a specific sort of string modification. Can someone help? John Ladasky <john_ladasky@sbcglobal.net> - 2013-01-06 21:39 -0800
Re: Need a specific sort of string modification. Can someone help? Nick Mellor <thebalancepro@gmail.com> - 2013-01-06 23:07 -0800
csiph-web