Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I feel the same way. Last week, I was surprised that `pow` in Python is actually a modpow: `pow(base, exp[, mod])`.

Also check https://pymotw.com/3/. It's a great tour of the Python standard library



And since 3.8 the exponent can be negative, which lets you compute modular inverses without having to reimplement the extended Euclidean algorithm.

    >>> pow(5, -1, 13)
    8
    >>> 5 * 8 % 13
    1


Huh, it's the little things that are the neatest surpises. Having to write the EEA multiple times during my crypto class to do the homework was a real pain in the ass.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: