10000 meta-issue: overloading improvements · Issue #265 · pythonnet/pythonnet · GitHub
[go: up one dir, main page]

Skip to content

meta-issue: overloading improvements #265

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
9 tasks
den-run-ai opened this issue Sep 16, 2016 · 6 comments
Closed
9 tasks

meta-issue: overloading improvements #265

den-run-ai opened this issue Sep 16, 2016 · 6 comments

Comments

@den-run-ai
Copy link
Contributor
den-run-ai commented Sep 16, 2016
@ArvidJB
Copy link
Contributor
ArvidJB commented Dec 27, 2016

How about the following idea: we could reuse the work that the DLR has already done to support correct overloading resolution (for IronPython). To use that we would first convert the Python arguments to their corresponding .NET types and then let the DLR decide which of the overloads to pick. This should add support for named arguments, generic type inference, etc.
I tinkered with this a bit and I think it would work correctly, but it would be a fairly major piece of work. Do you think this is a worthwhile route to pursue? It would add a reference to https://github.com/IronLanguages/dlr to python.net by adding this NuGet package https://www.nuget.org/packages/DynamicLanguageRuntime/

@den-run-ai
Copy link
Contributor Author

@ArvidJB this is interesting suggestion. One problem I see is that conversion from Python to .NET types can still be ambiguous even before letting DLR to do the overloading resolution. For example, passing a float could be converted to a single or a double, passing an integer could be converted to int16, int32, or int64.

Here are some comments from @matthid where he suggested to use Roslyn for this:

#203 (comment)

@AlexCatarino
Copy link
Contributor

@denfromufa, you haven't listed "named arguments".
I guess it is not support by @ArvidJB's comment.
Our experience at QuantConnect is that it is not. Could you please confirm?

@den-run-ai
Copy link
Contributor Author

@AlexCatarino probably not, can you provide a failing case not working for you?

@jaredbroad
Copy link

Fairly specific to our API but: it silently defaults as if the named args aren't there.

class BasicTemplateAlgorithm(QCAlgorithm):

    def Initialize(self):

        self.SetStartDate(2013,10,07)  #Set Start Date
        self.SetEndDate(2013,10,11)    #Set End Date
        self.SetCash(100000)           #Set Strategy Cash 
        self.AddEquity("SPY", Resolution.Minute, market=Market.USA, fillDataForward=False, leverage=1, extendedMarketHours=True)
        #self.AddEquity("SPY", Resolution.Minute, Market.USA, True, 1, True)

    def OnData(self, data):
        if not self.Portfolio.Invested:
            self.LimitOrder("SPY", 100, 200)

In the working case the trade occurs at 4.01am; in the default case its 9.31am.

https://www.quantconnect.com/terminal/processCache/?request=embedded_backtest_fa3f24864893dd26a7ed8d5a7d23a336.html

@den-run-ai
Copy link
Contributor Author

lostmsu added a commit to losttech/pythonnet that referenced this issue Feb 11, 2019
lostmsu added a commit to losttech/pythonnet that referenced this issue Jun 26, 2019
filmor pushed a commit that referenced this issue Jun 28, 2019
…#900)

* generate more useful message, when a .NET overload can't be found, that matches Python parameter types
* provide detailed error message, when an overload can't be found when calling C# from Python

Related: #811, #265, #782
lostmsu added a commit to losttech/pythonnet that referenced this issue May 14, 2020
…tails

Similar to pythonnet#900, but for constructors (reuses the same code)

Related issues: pythonnet#811, pythonnet#265, pythonnet#1116
filmor pushed a commit that referenced this issue May 14, 2020
…tails (#1143)

Similar to #900, but for constructors (reuses the same code)

Related issues: #811, #265, #1116
AlexCatarino pushed a commit to QuantConnect/pythonnet that referenced this issue Jun 18, 2020
…pythonnet#900)

* generate more useful message, when a .NET overload can't be found, that matches Python parameter types
* provide detailed error message, when an overload can't be found when calling C# from Python

Related: pythonnet#811, pythonnet#265, pythonnet#782
AlexCatarino pushed a commit to QuantConnect/pythonnet that referenced this issue Jun 29, 2020
@filmor 5492 filmor closed this as not planned Won't fix, can't repro, duplicate, stale Aug 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants
0