Skip to content
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

Are functions hashable? #296

Open
brandjon opened this issue Jan 10, 2025 · 1 comment
Open

Are functions hashable? #296

brandjon opened this issue Jan 10, 2025 · 1 comment

Comments

@brandjon
Copy link
Member

From @alandonovan's comment in a prior issue:

% starlark
Welcome to Starlark (go.starlark.net)
>>> {len: 1}
{<built-in function len>: 1}
>>> len in {}
False
>>> {}.get(len, False)
False

% python2
Python 2.7.17rc1 (default, Oct 10 2019, 10:26:01) 
>>> {len: 1}
{<built-in function len>: 1}
>>> len in {}
False
>>> {}.get(len, False)
False


% python3.8
Python 3.8.1 (default, Dec 31 2019, 14:30:41) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> {len: 1}
{<built-in function len>: 1}
>>> len in {}
False
>>> {}.get(len, False)
False

% blaze-bin/third_party/bazel/src/main/java/com/google/devtools/starlark/Starlark
>> {len: 1}
unhashable type: 'function'
>> len in {}
unhashable type: 'function'
>> {}.get(len, False)
unhashable type: 'function'
@brandjon
Copy link
Member Author

Note that for Bazel, function hashability is also related to concerns around serializing and fingerprinting/digesting functions. The details of which are not all paged into my head right now...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant