Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: ram@zedat.fu-berlin.de (Stefan Ram) Newsgroups: comp.lang.python,comp.lang.c Subject: Re: myrkraverk.c Date: 20 Sep 2026 13:48:21 GMT Organization: Stefan Ram Lines: 28 Expires: 1 Sep 2027 11:59:58 GMT Message-ID: References: <118mo9b$2i0j0$1@dont-email.me> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Trace: news.uni-berlin.de y2EZZhrAXTdZT61J3n1s+AAb2oQfleRjYW/nt2DVBMif1K Cancel-Lock: sha1:8sc59gI0r4PJfsw6lC5M9R2Ezqk= sha256:yKXkjhQ5c1o4C7ZSDIHY9WfMiDKJm8Ayhia1VwsY4N0= X-Copyright: (C) Copyright 2026 Stefan Ram. All rights reserved. Distribution through any means other than regular usenet channels is forbidden. It is forbidden to publish this article in the Web, to change URIs of this article into links, and to transfer the body without this notice, but quotations of parts in other Usenet posts are allowed. X-No-Archive: Yes Archive: no X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some services to mirror the article in the web. But the article may be kept on a Usenet archive server with only NNTP access. X-No-Html: yes Content-Language: en Xref: csiph.com comp.lang.python:198037 comp.lang.c:402301 "Johann \"Myrkraverk\" Oskarsson" wrote or quoted: >Perhaps I should have made that clearer in the code comments? No, I was too focused on just that one line, not paying attention to the global context. >A bit more worrying is that I do not off hand know how to time my cre- >ation. This is because /timeit/ can't find it. Maybe you can pass the globals which should contain the name "count_lsb": timeit.timeit("count_lsb(1 << 125)", globals=globals()) . The optional "globals" argument specifies a namespace in which to execute the code. You could also try the pattern, start_time = timeit.default_timer() count_lsb(1<<125) dt = timeit.default_timer() - start_time . However, when "count_lsb(1<<125)` is very fast, the results might be less accurate. (You can ask your chatbot about "pitfalls of microbenchmarks in Python".)