Santiago Romero wrote:
How about
   page, index = divmod(address, 16384)

 Surely, much better and faster :-)

Not necessarily, because it involves a function call,
and constructing and deconstructing a result tuple.
If you time them, you may well find that the explicit
shift and mask operations turn out to be faster.

That also goes for any of the other things being
discussed here. Especially if you're used to C, one's
intuitions about speed can go badly astray where
Python is concerned. The only way to be sure is to
measure!

--
Greg
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to