Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

How to Compare Reference Equality of Value Objects in pythonnet Without Using Obsolete PyObject.Handle #2603

Closed
@ljnober

Description

@ljnober

When working with value objects converted from pybind11, some objects override the equality operator (==). In such cases, I need to compare objects based on reference equality instead of value equality. In Python, this is typically done using id(obj) or the is operator to check if two variables point to the same object .

In pythonnet, I attempted to use PyObject.Handle for this purpose, but it is marked as obsolete . What is the recommended way to achieve reference equality comparisons in pythonnet now? For example:

  • Can Python’s built-in id() function be used directly?
  • Are there alternative APIs in pythonnet to replace PyObject.Handle?
    This is critical for ensuring correct comparisons of objects where value-based equality is intentionally overridden.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp