New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a builtin for population counting / hamming distance #10757

brtzsnr opened this Issue May 8, 2015 · 1 comment


None yet
3 participants

brtzsnr commented May 8, 2015

This feature was requested before #4988 but the bug was closed as WAI. I believe having popcnt part of standard library would benefit greatly many libraries.

For example there are two popcnt implementation in the golang tools:

It is also provided by several third party libraries

These implementation are incomplete: the libraries provide assembly for one platform (amd64 in the best case), may not be not inlined (function call will dominate the benchmarks, are not well test, or are under a restrictive licence.

There is also a long standing bug #4816 which requests the POPCNT instruction on amd64. With POPCNT instruction population counting can be turned into a single instruction similarly to math.Sqrt (

popcnt is very often used by chess, go (the game), checkers engines, all of them would benefit from a fast popcnt. #7357 provides another real word usage. Also a Go developer expressed his wish for popcnt (and other similar operations) to be provided by the standard library (


This comment has been minimized.

Show comment
Hide comment

robpike May 8, 2015


Duplicate of #4988

No need for this to be in the standard library.


robpike commented May 8, 2015

Duplicate of #4988

No need for this to be in the standard library.

@robpike robpike closed this May 8, 2015

@golang golang locked and limited conversation to collaborators Jun 25, 2016

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.