6 ms·
That is a) hauling in an awfully big external library for something that should be relatively trivial, b) inefficient (you're replacing a single multiplication
by TheLoneWolfling 11y ago
That is a) hauling in an awfully big external library for something that should be relatively trivial, b) inefficient (you're replacing a single multiplication by 10 and addition per digit with O(log x) multiplications and an addition per digit, assuming np.power uses a decent exponentiation algorithm), and c) if anything, less readable than my version.
To put it simply, I don't see an improvement with that version.
And Python 3 has some improvements w.r.t. wildcard arguments.
- bpicolo 11y agoIf you don't need other bases you can just string join them. : P
- TheLoneWolfling 11y agoThat's actually how I started, and `int` has a base parameter. But it's still relatively verbose, due to Python's whole "join-only-takes-strings" thing: def valueOf(*values, base=10): return int("".join(map(str, values)), base=10) Not to mention it's doing a whole lot of unnecessary work.
- TheLoneWolfling 11y agoWhoops. Miscopied. the second `=10` shouldn't be there.