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

literal_unroll needs to know about types.Named*Tuple #5322

Closed
2 tasks done
stuartarchibald opened this issue Feb 27, 2020 · 0 comments · Fixed by #5325
Closed
2 tasks done

literal_unroll needs to know about types.Named*Tuple #5322

stuartarchibald opened this issue Feb 27, 2020 · 0 comments · Fixed by #5325
Assignees
Labels

Comments

@stuartarchibald
Copy link
Contributor

Reporting a bug

This was reported here: https://gitter.im/numba/numba?at=5e57e6a186e6ec2f5c6466a6

from collections import namedtuple
from numba import njit, literal_unroll

ABC = namedtuple('ABC', ['a', 'b', 'c'])

@njit
def unroll(x):
    for z in literal_unroll(x):
        print(z)

abc = ABC(1, 2, 3)
print(unroll(abc))

does this

Invalid use of literal_unroll with a function argument, only tuples are supported as function arguments, found ABC(int64 x 3)

As the Numba internal Python 3.8 tuple __hash__ alg uses literal_unroll, the above issue breaks hashing on named tuples in Python 3.8.

@stuartarchibald stuartarchibald self-assigned this Feb 27, 2020
stuartarchibald added a commit to stuartarchibald/numba that referenced this issue Feb 28, 2020
As title. This type class was missed in the original
implementation, as it behaves like a standard tuple simply
changing the guard to accept the type seems sufficient.

Tests added.

Fixes numba#5322
stuartarchibald added a commit to stuartarchibald/numba that referenced this issue Feb 28, 2020
As title. This type class was missed in the original
implementation, as it behaves like a standard tuple simply
changing the guard to accept the type seems sufficient.

Tests added.

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

Successfully merging a pull request may close this issue.

1 participant