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

Improve method binding#974

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
koubaa wants to merge11 commits intopythonnet:masterfromkoubaa:ienumerable
Closed

Conversation

koubaa
Copy link
Contributor

@koubaakoubaa commentedOct 21, 2019
edited
Loading

What does this implement/fix? Explain your changes.

Two method binding changes:
Support passing lists/tuples to methods which take IEnumerable, ICollection, IList
Support passing functions to methods which take Action, Func, Task

Does this close any currently open issues?

Not that I am aware of.

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 toAUTHORS
  • Updated theCHANGELOG

change enumerable method to non-staticadd tuple test for ienumerable
@koubaa
Copy link
ContributorAuthor

koubaa commentedDec 1, 2019
edited
Loading

@filmor@lostmsu@amos402 I am still working on the implementation here (the ToAction method throws a memory corruption error in py_action.Invoke) but would appreciate some preliminary review to make sure I'm headed in the right direction. Thanks!

@koubaakoubaa changed the titleAdd test for ienumerable methodImprove method bindingDec 1, 2019
@koubaa
Copy link
ContributorAuthor

allow_threads in methodbinder.cs Invoke is true which is causing the memory corruption. If I set it to false there is no corruption so I need to look into why. This looks like it may be new code

Copy link
Member

@lostmsulostmsu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I honestly think we'd be better off not introducing additional automatic conversions at this moment.

Comment on lines 948 to 956
Action action = () => {
PyObject py_action = new PyObject(value);
var py_args = new PyObject[0];
var py_result = py_action.Invoke(py_args);

//Discard the result since this is being converted to an Action
py_result.Dispose();
py_action.Dispose();
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

The object pointed to byvalue can be collected between the construction of thisaction, and the moment it is invoked. It would lead to a memory corruption.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I had forgotten to push the latest change set, please check again

Copy link
ContributorAuthor

@koubaakoubaa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I honestly think we'd be better off not introducing additional automatic conversions at this moment.

That's an acceptable position. I'll bring this PR up at tomorrow's meeting and will like to hear from the group on how to proceed

@amos402
Copy link
Member

Not suggesting this readonly implicit conversion, what if I want to use like this

voidAddElem(IList<int>lst){lst.add(10);}
deffunc():lst= [1,2,3]AddElem(lst)# I want [1,2,3,10] actually

I suggest implement some subclasses from List<> so you can track the changes of the collection and apply them to the Python's list
Also the test didn't check any outputs, it only certify the runtime has no exceptions.

@koubaa
Copy link
ContributorAuthor

@amos402 see the latest changes. I'm dealing with some crash/exception in native code but I think I'm going in the direction that you are proposing.

@koubaa
Copy link
ContributorAuthor

@lostmsu since we last spoke I looked into codec and it looks like string encoding, so I'm not sure how it could apply to method binding. What is your preferred way to support non-automatic conversions for me to consider/try?

Runtime.XIncref(iterObject);
}
~IterableWrapper() {
Runtime.XDecref(iterObject);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

You can't useXDecref directly in destructor, seeRuntime.PyObject's destructor, you can just refer aPyObject, it can let you have no need concern about about the release.

@lostmsu
Copy link
Member

Opened#1022 for my take on generic approach.

@koubaa
Copy link
ContributorAuthor

This is superseded by#1084 and#1080

@koubaakoubaa closed thisMar 11, 2020
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@amos402amos402amos402 left review comments

@lostmsulostmsulostmsu requested changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@koubaa@amos402@lostmsu

[8]ページ先頭

©2009-2025 Movatter.jp