Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: Bitshifts and "And" vs Floor-division and Modular

Reply
Thread Tools

Re: Bitshifts and "And" vs Floor-division and Modular

 
 
Mark Lawrence
Guest
Posts: n/a
 
      09-07-2012
On 07/09/2012 02:08, Cameron Simpson wrote:
> On 07Sep2012 01:30, Mark Lawrence <(E-Mail Removed)> 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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Bitshifts and "And" vs Floor-division and Modular jimbo1qaz Python 12 09-07-2012 04:59 PM
Supply Telephone Voice Modular Adapters,Telephone Modular Couplers,Modular Duplex Jack,Triplex Adapters,Telephone extension Cord samul888@vip.163.com Cisco 1 11-13-2005 09:23 AM
Supply Telephone Voice Modular Adapters,Telephone Modular Couplers,Modular Duplex Jack,Triplex Adapters,Telephone extension Cord samul888@vip.163.com Computer Support 0 11-12-2005 06:22 AM
Supply Telephone Voice Modular Adapters,Telephone Modular Couplers,Modular Duplex Jack,Triplex Adapters,Telephone extension Cord samul888@vip.163.com VOIP 0 11-12-2005 06:22 AM



Advertisments