def METHOD_NAME(mask):
    # make sure the correct ULONG_PTR size is used on 64bit
    # https://docs.microsoft.com/en-us/windows/
    # desktop/WinProg/windows-data-types
    # note: not a pointer per-se, != PULONG_PTR
    ulong_ptr = c_ulonglong if sizeof(c_void_p) == 8 else c_ulong
    # note: c_ulonglong only on 64bit, otherwise c_ulong
    # DWORD == c_uint32
    # https://docs.microsoft.com/en-us/windows/
    # desktop/WinProg/windows-data-types
    lshift = c_uint32(sizeof(ulong_ptr) * 8 - 1)
    assert lshift.value in (31, 63), lshift  # 32 or 64 bits - 1
    lshift = lshift.value
    test = 1 << lshift
    assert test % 2 == 0, test
    count = 0
    i = 0
    while i <= lshift:
        i += 1
        # do NOT remove!!!
        # test value has to be %2 == 0,
        # except the last case where the value is 1,
        # so that int(test) == int(float(test))
        # and the mask bit is counted correctly
        assert test % 2 == 0 or float(test) == 1.0, test
        # https://stackoverflow.com/a/1746642/5994041
        # note: useful to print(str(bin(int(...)))[2:])
        count += 1 if (mask & int(test)) else 0
        test /= 2
    return count