log2 in python math module

why doesn’t it exist?

import math

[x for x in dir(math) if ‘log’ in x]

>>> [‘log’, ‘log10’, ‘log1p’]

I know I can do log(x,2), but log2 is really common, so I’m kind of baffled.

Oh, it looks like it’s only defined in C99, not C90, I guess that answers my question. Still seems kind of silly.

Leave a Comment