← Winnitude! Search  ·  Reader Mode (1816 ms)
Links: Stay in Reader Retro Site Converter Retro Mode: OFF Original Page ↗
GITHUB · 43 LINKS

`IComparable` and `IEquatable` implementations by lostmsu · Pull Request #2322 · pythonnet/pythonnet

Repository navigation

IComparable and IEquatable implementations - #2322


Merged
lostmsu merged 1 commit into pythonnet:master from losttech:ComparableEquatable Feb 28, 2024
Merged

IComparable and IEquatable implementations #2322 lostmsu merged 1 commit into pythonnet:master from losttech:ComparableEquatable

Conversation

lostmsu commented Feb 15, 2024 · edited Loading



Copy link Copy Markdown
Member

IComparable and IEquatable implementations for PyInt, PyFloat, and PyString for primitive .NET types

What does this implement/fix? Explain your changes.

Let's one do PyInt.CompareTo(42) and similar things

Does this close any currently open issues?

N/A

Any other comments?

Should we take GIL in these methods? Might be useful for Array.Sort when called from Python.

On a more general topic: should we have a way for Python to call a .NET method and have it not release the GIL for compatibility with 3rd party (to Python.NET) libraries that assume they can call back any methods they wish at any time. Because having explicit GIL acquisition in CompareTo to use with Array.Sort would kill performance. E.g. something like:

with clr.HoldGIL():
  Array.Sort(dotnet_array_of_python_objects)

Checklist

Check all those that are applicable and complete.

  • Make sure to include one or more tests for your change
  • If an enhancement PR, please create docs and at best an example
  • Add yourself to AUTHORS
  • Updated the CHANGELOG
lostmsu requested a review from filmor February 27, 2024 03:14 filmor approved these changes Feb 28, 2024
View reviewed changes

filmor commented Feb 28, 2024



Copy link Copy Markdown
Member

Regarding the GIL, maybe we could a custom thread local ref count could speed things up?

lostmsu force-pushed the ComparableEquatable branch from 3e27819 to f3d8c60
Compare
February 28, 2024 19:57 IComparable and IEquatable implementations for PyInt, PyFloat, and Py... f738505
...String for primitive .NET types
lostmsu force-pushed the ComparableEquatable branch 2 times, most recently from ebab183 to f738505
Compare
February 28, 2024 20:08 lostmsu merged commit 563e369 into pythonnet : master Feb 28, 2024 lostmsu deleted the ComparableEquatable branch February 28, 2024 21:46 dependabot
Bot
mentioned this pull request Jan 16, 2026 Bump pythonnet from 3.0.3 to 3.0.5 mattemangia/Deep3DStudio#99 Closed Sign up for free to join this conversation on GitHub . Already have an account? Sign in to comment

Labels

None yet

2 participants