Eric Osborne <e...@notcom.com> added the comment: Faster, too. My way: In [7]: %timeit bits(a) 1.67 µs ± 7.31 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)
Your way: In [11]: %timeit b2(a) 1.2 µs ± 5.93 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each) I was a little worried about doing it all as a clever one-liner but this seems worthwhile. I'll change the code I submitted. thanks! eric On Sun, Feb 11, 2018 at 6:21 PM Eric V. Smith <rep...@bugs.python.org> wrote: > > Eric V. Smith <e...@trueblade.com> added the comment: > > Without commenting on how useful or desirable this would be, I'll point > out the string can be computed as: > > return f'{int(self):#0{IPV4LENGTH+2}b}' > > ---------- > nosy: +eric.smith > > _______________________________________ > Python tracker <rep...@bugs.python.org> > <https://bugs.python.org/issue32820> > _______________________________________ > ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue32820> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com