Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #61186
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.kamp.net!newsfeed.kamp.net!feeder1.cambriumusenet.nl!feed.tweaknews.nl!194.109.133.86.MISMATCH!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <joel.goldstick@gmail.com> |
| 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; 'algorithm': 0.04; 'memory.': 0.07; 'modified': 0.07; 'computed': 0.09; 'friday,': 0.09; 'lines.': 0.09; 'python:': 0.09; 'referenced': 0.09; 'statements': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; '(assuming': 0.16; 'comments:': 0.16; 'relevant.': 0.16; 'sure.': 0.16; 'variable.': 0.16; '\xc2\xa0i': 0.16; '\xc2\xa0if': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'looked': 0.18; '<': 0.19; '>>>': 0.22; 'example': 0.22; 'python?': 0.22; 'cc:addr:python.org': 0.22; '>>>': 0.24; 'cc:2**0': 0.24; '>': 0.26; 'references': 0.26; 'this:': 0.26; 'second': 0.26; 'read,': 0.26; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'am,': 0.29; 'dec': 0.30; 'robert': 0.30; 'start,': 0.30; 'message-id:@mail.gmail.com': 0.30; 'url:mailman': 0.30; 'code': 0.31; 'lines': 0.31; "skip:' 10": 0.31; 'url:wiki': 0.31; 'end,': 0.31; 'subject:some': 0.31; 'url:wikipedia': 0.31; 'quite': 0.32; 'url:python': 0.33; 'fri,': 0.33; 'implemented': 0.33; 'minimal': 0.33; 'december': 0.35; 'operations': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'really': 0.36; 'described': 0.36; 'false': 0.36; 'largely': 0.36; 'url:listinfo': 0.36; 'url:org': 0.36; 'two': 0.37; 'performance': 0.37; 'skip:& 10': 0.38; 'url:mail': 0.40; 'how': 0.40; 'read': 0.60; 'algorithms': 0.60; 'john': 0.61; 'simple': 0.61; 'discuss': 0.62; 'more': 0.64; 'benefit': 0.68; 'deeply': 0.69; 'below.': 0.71; 'completely,': 0.84; 'draws': 0.84; 'raster': 0.84; 'old,': 0.85; 'joel': 0.91; 'write:': 0.91; '2013': 0.98 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=e8Xgq01bXUMK1P69icPH5yFdbHyYWtvVDfPAj5EyxK4=; b=n/scXAPEL9G/k3rRDn1AvYeO6id6v2nY1o1hTGA3p3uEpuPCZIhRxL2lIr0ITU6FnG d20gKj0X3TAz3OdRCVJRIQEahPRa58B6HvNeP11bGJoSynZnL1hGmak3I5HUZeclOMcz 3PrVAaVIECFn65re4Nrcowry1lMlvL8D5bX82g78LHFOySohsQ6998GkhD772Drh7bxJ 9Hz3/aeBWHntzhHOAeV468ONSSJr0FKARZII3rXg6eosIBg10+edNkh5dI9P9/A9c25R 1dzirrJzJwdbREM6MgGHO9h+B3iTLKzyxJ5LYqDbhC1qvoO6bcHmSC6xHkAMiu3VESvl Qo0g== |
| MIME-Version | 1.0 |
| X-Received | by 10.52.172.68 with SMTP id ba4mr2080462vdc.66.1386367676734; Fri, 06 Dec 2013 14:07:56 -0800 (PST) |
| In-Reply-To | <9df6ccd7-828d-43be-ac49-fe1c6a38bae7@googlegroups.com> |
| References | <ce6477c1-29c0-43b3-9e56-336a5825869b@googlegroups.com> <9df6ccd7-828d-43be-ac49-fe1c6a38bae7@googlegroups.com> |
| Date | Fri, 6 Dec 2013 17:07:56 -0500 |
| Subject | Re: squeeze out some performance |
| From | Joel Goldstick <joel.goldstick@gmail.com> |
| To | John Ladasky <john_ladasky@sbcglobal.net> |
| Content-Type | multipart/alternative; boundary=089e0160bc6ee6934504ece4e0a0 |
| Cc | "python-list@python.org" <python-list@python.org> |
| 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.3667.1386368018.18130.python-list@python.org> (permalink) |
| Lines | 156 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1386368018 news.xs4all.nl 2882 [2001:888:2000:d::a6]:37525 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:61186 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
On Fri, Dec 6, 2013 at 11:52 AM, John Ladasky <john_ladasky@sbcglobal.net>wrote:
> On Friday, December 6, 2013 12:47:54 AM UTC-8, Robert Voigtländer wrote:
>
> > I try to squeeze out some performance of the code pasted on the link
> below.
> > http://pastebin.com/gMnqprST
>
Not that this will speed up your code but you have this:
if not clockwise:
s = start
start = end
end = s
Python people would write:
end, start = start, end
You have quite a few if statements that involve multiple comparisons of the
same variable. Did you know you can do things like this in python:
>>> x = 4
>>> 2 < x < 7
True
>>> x = 55
>>> 2 < x < 7
False
> Several comments:
>
> 1) I find this program to be very difficult to read, largely because
> there's a whole LOT of duplicated code. Look at lines 53-80, and lines
> 108-287, and lines 294-311. It makes it harder to see what this algorithm
> actually does. Is there a way to refactor some of this code to use some
> shared function calls?
>
> 2) I looked up the "Bresenham algorithm", and found two references which
> may be relevant. The original algorithm was one which computed good raster
> approximations to straight lines. The second algorithm described may be
> more pertinent to you, because it draws arcs of circles.
>
> http://en.wikipedia.org/wiki/Bresenham's_line_algorithm
> http://en.wikipedia.org/wiki/Midpoint_circle_algorithm
>
> Both of these algorithms are old, from the 1960's, and can be implemented
> using very simple CPU register operations and minimal memory. Both of the
> web pages I referenced have extensive example code and pseudocode, and
> discuss optimization. If you need speed, is this really a job for Python?
>
> 3) I THINK that I see some code -- those duplicated parts -- which might
> benefit from the use of multiprocessing (assuming that you have a
> multi-core CPU). But I would have to read more deeply to be sure. I need
> to understand the algorithm more completely, and exactly how you have
> modified it for your needs.
> --
> https://mail.python.org/mailman/listinfo/python-list
>
--
Joel Goldstick
http://joelgoldstick.com
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
squeeze out some performance Robert Voigtländer <r.voigtlaender@gmail.com> - 2013-12-06 00:47 -0800
Re: squeeze out some performance Jeremy Sanders <jeremy@jeremysanders.net> - 2013-12-06 10:46 +0100
Re: squeeze out some performance Chris Angelico <rosuav@gmail.com> - 2013-12-06 23:13 +1100
Re: squeeze out some performance Robert Voigtländer <r.voigtlaender@gmail.com> - 2013-12-06 08:29 -0800
Re: squeeze out some performance Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-12-06 16:36 +0000
Re: squeeze out some performance Robert Voigtländer <r.voigtlaender@gmail.com> - 2013-12-06 08:44 -0800
Re: squeeze out some performance John Ladasky <john_ladasky@sbcglobal.net> - 2013-12-06 08:52 -0800
Re: squeeze out some performance Joel Goldstick <joel.goldstick@gmail.com> - 2013-12-06 17:07 -0500
Re: squeeze out some performance Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-12-06 22:38 +0000
Re: squeeze out some performance Dan Stromberg <drsalists@gmail.com> - 2013-12-06 15:01 -0800
Re: squeeze out some performance Robert Voigtländer <r.voigtlaender@gmail.com> - 2013-12-09 06:19 -0800
Re: squeeze out some performance Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-12-09 14:52 +0000
Re: squeeze out some performance Robin Becker <robin@reportlab.com> - 2013-12-09 15:54 +0000
Re: squeeze out some performance Dave Angel <davea@davea.name> - 2013-12-09 15:46 -0500
Re: squeeze out some performance Robin Becker <robin@reportlab.com> - 2013-12-10 12:54 +0000
Re: squeeze out some performance Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-12-09 23:57 +0000
Re: squeeze out some performance Robert Voigtländer <r.voigtlaender@gmail.com> - 2013-12-10 04:14 -0800
csiph-web