Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #63846
| Path | csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.002 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'package,': 0.03; 'board.': 0.05; 'canvas': 0.07; 'needed,': 0.07; 'see:': 0.07; 'canvas.': 0.09; 'second.': 0.09; 'runs': 0.10; 'python': 0.11; 'jan': 0.12; 'deleted,': 0.16; 'efficiency.': 0.16; 'iteration': 0.16; 'itself,': 0.16; 'loop.': 0.16; 'reposition': 0.16; 'seconds.': 0.16; 'underlying': 0.16; 'fix': 0.17; 'wrote:': 0.18; 'module': 0.19; 'trying': 0.19; 'drawing': 0.19; 'appears': 0.22; 'adds': 0.24; 'documented': 0.24; 'please?': 0.24; 'mon,': 0.24; 'looks': 0.24; 'url:edu': 0.26; 'developing': 0.27; 'gets': 0.27; 'header :In-Reply-To:1': 0.27; 'point': 0.28; 'function': 0.29; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; 'lines': 0.31; '13,': 0.31; 'disable': 0.31; 'anyone': 0.31; 'front': 0.32; 'option': 0.32; 'url:python': 0.33; 'running': 0.33; 'moment': 0.34; 'could': 0.34; 'problem': 0.35; 'display': 0.35; 'objects': 0.35; 'received:google.com': 0.35; 'animation': 0.36; 'done': 0.36; 'doing': 0.36; 'method': 0.36; 'wrong': 0.37; 'window': 0.38; 'to:addr:python-list': 0.38; 'rather': 0.38; 'explain': 0.39; 'does': 0.39; 'to:addr:python.org': 0.39; 'enough': 0.39; 'either': 0.39; 'called': 0.40; 'remove': 0.60; 'new': 0.61; 'simply': 0.61; 'simple': 0.61; "you're": 0.61; 'first': 0.61; 'here:': 0.62; 'times': 0.62; 'teaching': 0.64; 'more': 0.64; 'rendering': 0.68; 'draws': 0.84; 'url:graphics': 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=z0p9saKSkclbRSJJrmEdIeGJU2AYWqwdj5Qe6kd8/C8=; b=olkRezW8IdDLduq2/z1mPMkcfHGLChjGycApA8O3COZs28Y3qDnZgtK3qDBKMPIiyS XNRdM7H23oE8rh2XLT0//WtL/yWZfKVB5XEAYfeujDYMHxmnrm/e4XSulzmrhQrfetLD Z9vFeb8sjL6nwpqiQsr1L8GshxAPTcVfDw43iAeWf+XF7BC2F7WhYNaHzRKrpWnRDLBc SzMbwQWfTIhRa3eCJhok0LtjZ0NeRpB4oAowhYX2cGll6kg5OQp+Ls64kSyphf1fAVZW 39QYC3e0c97AVT8kYxM/7F0j4OJH3oDFzJIybwllJSoHQlUR9t9PKZTIx6suYXxmv3bI Wicg== |
| X-Received | by 10.68.213.41 with SMTP id np9mr31085637pbc.90.1389636347468; Mon, 13 Jan 2014 10:05:47 -0800 (PST) |
| MIME-Version | 1.0 |
| In-Reply-To | <4c51b5e8-e7b4-4a09-95d4-daefbfe27b28@googlegroups.com> |
| References | <4c51b5e8-e7b4-4a09-95d4-daefbfe27b28@googlegroups.com> |
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | Mon, 13 Jan 2014 11:05:06 -0700 |
| Subject | Re: plotting slows down |
| 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 | <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.5420.1389636350.18130.python-list@python.org> (permalink) |
| Lines | 38 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1389636350 news.xs4all.nl 2836 [2001:888:2000:d::a6]:43425 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:63846 |
Show key headers only | View raw
On Mon, Jan 13, 2014 at 1:15 AM, <norman.elliott@gmail.com> wrote: > First let me say I have not done much python programming! > I am running Python 2.7.3. > I am trying to use python as a front end to a simple oscilloscope. > Ultimately I intend to use it with my micropython board. > > At the moment I am just developing it. All it does is use a module I found called graphics.py to create a window and display randomly generated data. > > Each time it goes through the outer loop it gets slower and slower. > I put in a small delay just so I could observe what is happening and for the first line it draws it takes about a second. If I set it to loop 20 times the final loop takes more than 6 seconds. > Can anyone explain what I am doing wrong please? I wager the problem is in the "range(1, xpos)" inner loop. Each time this runs the win.plot() call adds a 1-pixel line to the underlying Tk canvas. These 1-pixel lines are never deleted, so they accumulate over each outer loop. Every time a new object is drawn, the canvas has to process all of the lines that have been drawn in order to redraw itself, and so it gets slower and slower. One simple fix you might try to improve the rendering efficiency is to disable the autoflush option documented here: http://mcsp.wartburg.edu/zelle/python/graphics/graphics/node14.html And then call the module-level update() function after each iteration of the outer loop to force things to redraw. In order to realistically use this module for animation it looks like you will at some point need to keep the number of graphics objects under some constant. To do this you could either reuse the existing objects by calling their "move" method to reposition them as needed, or simply remove them from the plot with the "undraw" method and draw new objects in their place. See: http://mcsp.wartburg.edu/zelle/python/graphics/graphics/node3.html If this still isn't fast enough for the number of objects you're drawing, then you may just need to find a new drawing package, as this one appears to be designed for teaching rather than efficiency.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
plotting slows down norman.elliott@gmail.com - 2014-01-13 00:15 -0800
Re:plotting slows down Dave Angel <davea@davea.name> - 2014-01-13 08:26 -0500
Re:plotting slows down Steven D'Aprano <steve@pearwood.info> - 2014-01-13 20:33 +0000
Re:plotting slows down Dave Angel <davea@davea.name> - 2014-01-14 04:39 -0500
Re: plotting slows down Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-01-14 08:48 -0500
Re: plotting slows down Norman Elliott <norman.elliott@gmail.com> - 2014-01-13 05:32 -0800
Re: plotting slows down Norman Elliott <norman.elliott@gmail.com> - 2014-01-13 05:45 -0800
Re: plotting slows down Dave Angel <davea@davea.name> - 2014-01-14 04:32 -0500
Re: plotting slows down Ian Kelly <ian.g.kelly@gmail.com> - 2014-01-13 10:39 -0700
Re: plotting slows down Chris Angelico <rosuav@gmail.com> - 2014-01-14 04:45 +1100
Re: plotting slows down Dave Angel <davea@davea.name> - 2014-01-13 13:05 -0500
Re: plotting slows down Norman Elliott <norman.elliott@gmail.com> - 2014-01-13 10:33 -0800
Re: plotting slows down Ian Kelly <ian.g.kelly@gmail.com> - 2014-01-13 11:05 -0700
Re: plotting slows down Terry Reedy <tjreedy@udel.edu> - 2014-01-13 16:42 -0500
Re: plotting slows down Norman Elliott <norman.elliott@gmail.com> - 2014-01-14 05:04 -0800
Re: plotting slows down Rustom Mody <rustompmody@gmail.com> - 2014-01-14 05:15 -0800
Re: plotting slows down Chris Angelico <rosuav@gmail.com> - 2014-01-15 00:36 +1100
Re: plotting slows down Norman Elliott <norman.elliott@gmail.com> - 2014-01-14 09:06 -0800
csiph-web