Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #28686
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| 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; 'output': 0.04; '(even': 0.05; 'binary': 0.05; '(especially': 0.07; 'responding': 0.07; 'python': 0.09; 'advice?': 0.09; 'lawrence': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; "they've": 0.09; "wouldn't": 0.11; 'suggest': 0.11; 'personally,': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'silly': 0.16; 'simpson': 0.16; 'wrote:': 0.17; 'certainly': 0.17; 'module': 0.19; 'issue.': 0.20; 'bit': 0.21; 'bar.': 0.22; 'cheers,': 0.23; 'posts': 0.23; "haven't": 0.23; 'so.': 0.24; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'fit': 0.26; 'implemented': 0.27; 'question': 0.27; "doesn't": 0.28; 'header:X-Complaints-To:1': 0.28; 'run': 0.28; 'post': 0.28; 'division': 0.29; 'measure': 0.29; 'sensible': 0.29; "i'm": 0.29; 'usually': 0.30; 'becomes': 0.30; 'helpful': 0.30; 'code': 0.31; 'point': 0.31; 'from:addr:yahoo.co.uk': 0.32; 'could': 0.32; 'choices': 0.33; 'idle': 0.33; 'shift': 0.33; 'to:addr:python- list': 0.33; 'operations': 0.33; "can't": 0.34; 'agree': 0.34; 'done': 0.34; 'list': 0.35; 'faster': 0.35; "won't": 0.35; 'received:org': 0.36; 'but': 0.36; 'subject:" ': 0.36; 'too': 0.36; 'possible': 0.37; 'bad': 0.37; 'being': 0.37; 'why': 0.37; 'subject:: ': 0.38; 'mark': 0.38; 'some': 0.38; 'description': 0.39; 'instead': 0.39; 'performance': 0.39; 'to:addr:python.org': 0.39; 'short': 0.39; 'subject:-': 0.40; 'header:Received:5': 0.40; 'your': 0.60; 'address': 0.60; 'real': 0.61; 'different': 0.63; 'more': 0.63; 'reached': 0.65; 'offer': 0.65; 'power': 0.74; 'benchmark': 0.84; 'start.': 0.84; 'subject:Floor': 0.84; 'yourself?': 0.84; 'refuse': 0.93; 'relating': 0.93 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
| Subject | Re: Bitshifts and "And" vs Floor-division and Modular |
| Date | Fri, 07 Sep 2012 14:24:13 +0100 |
| References | <k2bf5u$ro8$1@ger.gmane.org> <20120907010830.GA25508@cskk.homeip.net> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Gmane-NNTP-Posting-Host | host-78-147-29-70.as13285.net |
| User-Agent | Mozilla/5.0 (Windows NT 6.0; rv:15.0) Gecko/20120824 Thunderbird/15.0 |
| In-Reply-To | <20120907010830.GA25508@cskk.homeip.net> |
| X-Antivirus | avast! (VPS 120907-0, 07/09/2012), Outbound message |
| X-Antivirus-Status | Clean |
| 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.355.1347024178.27098.python-list@python.org> (permalink) |
| Lines | 49 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1347024178 news.xs4all.nl 6885 [2001:888:2000:d::a6]:46476 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:28686 |
Show key headers only | View raw
On 07/09/2012 02:08, Cameron Simpson wrote: > On 07Sep2012 01:30, Mark Lawrence <breamoreboy@yahoo.co.uk> wrote: > | On 07/09/2012 01:01, jimbo1qaz wrote: > | > Is it faster to use bitshifts or floor division? And which is better, & or %? > | > All divisors and mods are power of 2, so are binary operations faster? And are they considered bad style? > | > | Why don't you use the timeit module and find out for yourself? > > Because timeit doesn't output style advice? > Because timeit won't offer even a short single parapgraph description > of how python ints (even just in CPython) are implemented and how that > may affect performance in general? > > To the OP: personally, I would suggest using % when I am thinking of > division and a bit shift when I am thinking of a bitshift, and only reach > for timeit when performance becomes an issue. Code for the algoritm, > and only optimise later. > > Of course only a well run benchmark will measure the real world, but it > possible to address his other questions in a helpful fashion and address > the benchmark question in a less offputting tone. If you can't be > bothered, please don't. (Especially since these irritating posts from > you are usually in response to a post you feel could have used more > effort from the OP.) > > Nobody answers all performance considerations or design choices with an > exhaustive timeit benchmark, and it is silly to suggest so. It is > helpful for people to have a mental model of the python internals > so they can make often-sensible choices from the start. > > So try being helpful instead of slapping people down when they haven't > reached your private bar. > > Cheers, > I'm sorry but I refuse point blank to spoon feed, fit bibs and change nappies. I wouldn't do that on the tutor mailing list and I certainly wouldn't do it here. If any OP is too bone idle to do some research and then pose a sensible question relating to what they want to achieve, what they've done to achieve it and what issues they've got then I intend responding in the same way. Clearly your approach is different so we'll have to agree to disagree. -- Cheers. Mark Lawrence.
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Bitshifts and "And" vs Floor-division and Modular Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-09-07 14:24 +0100
csiph-web