{"action":"created","issue":{"url":"https://api.github.com/repos/numba/numba/issues/3599","repository_url":"https://api.github.com/repos/numba/numba","labels_url":"https://api.github.com/repos/numba/numba/issues/3599/labels{/name}","comments_url":"https://api.github.com/repos/numba/numba/issues/3599/comments","events_url":"https://api.github.com/repos/numba/numba/issues/3599/events","html_url":"https://github.com/numba/numba/issues/3599","id":391224615,"node_id":"MDU6SXNzdWUzOTEyMjQ2MTU=","number":3599,"title":"Njitted permutations","user":{"login":"fingoldo","id":16359856,"node_id":"MDQ6VXNlcjE2MzU5ODU2","avatar_url":"https://avatars3.githubusercontent.com/u/16359856?v=4","gravatar_id":"","url":"https://api.github.com/users/fingoldo","html_url":"https://github.com/fingoldo","followers_url":"https://api.github.com/users/fingoldo/followers","following_url":"https://api.github.com/users/fingoldo/following{/other_user}","gists_url":"https://api.github.com/users/fingoldo/gists{/gist_id}","starred_url":"https://api.github.com/users/fingoldo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fingoldo/subscriptions","organizations_url":"https://api.github.com/users/fingoldo/orgs","repos_url":"https://api.github.com/users/fingoldo/repos","events_url":"https://api.github.com/users/fingoldo/events{/privacy}","received_events_url":"https://api.github.com/users/fingoldo/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-12-14T18:48:49Z","updated_at":"2018-12-14T19:23:04Z","closed_at":null,"author_association":"NONE","body":"Hello, I'm trying to get permutations from a list of integers:\r\n\r\n```python\r\n@numba.njit()\r\ndef permutations(A, k):\r\n    r = [[]]\r\n    for i in range(k):\r\n        t=[]\r\n        for next_num in A:\r\n            for next_chain in r:            \r\n                if next_num not in next_chain:\r\n                    t.append([next_num,] + next_chain)\r\n        r=t\r\n    return r\r\npermutations([1,2,3],3)\r\n```\r\n\r\nwith numba decorator commented out, result is as expected:\r\n[[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1]]\r\n\r\nOtherwise, it's giving me various errors which make no sense:\r\n```\r\n\r\nTypingError: Failed in nopython mode pipeline (step: nopython frontend)\r\nUndefined variable 'next_chain', operation: $phi42.1, location: <ipython-input-113-8321626fa1fb> (7)\r\n\r\nFile \"<ipython-input-113-8321626fa1fb>\", line 7:\r\ndef permutations(A, k):\r\n    <source elided>\r\n        for next_num in A:\r\n            for next_chain in r:\r\n\r\n```\r\nPlease advise )\r\n\r\nPython version: ['3.6.3 |Anaconda, Inc.| (default, Oct 15 2017, 03:27:45) [MSC v.1900 64 bit (AMD64)]'] \r\nplatform: AMD64 \r\nsystem: Windows-10-10.0.14393-SP0 \r\nNumba version: 0.41.0"},"comment":{"url":"https://api.github.com/repos/numba/numba/issues/comments/447428201","html_url":"https://github.com/numba/numba/issues/3599#issuecomment-447428201","issue_url":"https://api.github.com/repos/numba/numba/issues/3599","id":447428201,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0NzQyODIwMQ==","user":{"login":"fingoldo","id":16359856,"node_id":"MDQ6VXNlcjE2MzU5ODU2","avatar_url":"https://avatars3.githubusercontent.com/u/16359856?v=4","gravatar_id":"","url":"https://api.github.com/users/fingoldo","html_url":"https://github.com/fingoldo","followers_url":"https://api.github.com/users/fingoldo/followers","following_url":"https://api.github.com/users/fingoldo/following{/other_user}","gists_url":"https://api.github.com/users/fingoldo/gists{/gist_id}","starred_url":"https://api.github.com/users/fingoldo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fingoldo/subscriptions","organizations_url":"https://api.github.com/users/fingoldo/orgs","repos_url":"https://api.github.com/users/fingoldo/repos","events_url":"https://api.github.com/users/fingoldo/events{/privacy}","received_events_url":"https://api.github.com/users/fingoldo/received_events","type":"User","site_admin":false},"created_at":"2018-12-14T19:23:04Z","updated_at":"2018-12-14T19:23:04Z","author_association":"NONE","body":"Final version, 3-liner:\r\n\r\n```python\r\n@numba.njit()\r\ndef permutations(A, k):\r\n    r = [[i for i in range(0)]]\r\n    for i in range(k):\r\n        r = [[a] + b for a in A for b in r if (a in b)==False]\r\n    return r\r\npermutations([1,2,3],3)\r\n```"}}
{"actor":{"display_login":"fingoldo"}}