numba/numba

The is operator in the jitted code does not work for structref instance.

Open

#9,936 opened on 2025年2月24日

GitHub で見る
 (8 comments) (0 reactions) (0 assignees)Python (1,132 forks)batch import
bug - miscompilegood first issue

Repository metrics

Stars
 (9,177 stars)
PR merge metrics
 (平均マージ 14d 16h) (30d で 30 merged PRs)

説明

Reporting a bug

Running the code below:

import platform, sys
import numba as nb
from numba import types, extending
from numba.experimental import structref

print(platform.platform(terse=True))
print(sys.version)
print(nb.__version__)

@structref.register
class NodeType(types.StructRef):
    pass
node_type = NodeType([])

class Node(structref.StructRefProxy):
    pass

@extending.overload(Node)
def ol_Node():
    def impl():
        self = structref.new(node_type)
        return self
    return impl

@nb.njit
def main():
    node = Node()
    print(node is node)

    List = [0]
    print(List is List)

    Tuple = (0,)
    print(Tuple is Tuple)

main()

resulted in:

Linux-6.1.85+-x86_64-with-glibc2.35
3.11.11 (main, Dec  4 2024, 08:55:07) [GCC 11.4.0]
0.61.0
False
True
True

As above in the title. I believe True will be printed, and the is operator is a good way to treat all instances as distinct and different. This is the first issue I've opened, so please let me know if there is anything I have not done or am unclear on.

コントリビューターガイド