Skip to content
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

Upgrade compiler to 7.3 #65

Open
irperez opened this issue Sep 15, 2018 · 5 comments
Open

Upgrade compiler to 7.3 #65

irperez opened this issue Sep 15, 2018 · 5 comments

Comments

@irperez
Copy link
Collaborator

irperez commented Sep 15, 2018

The latest compiler version 7.3 allows us to take advantage of some good performance features that were not available.

In particular the use of ref, in, out keywords in ways not possible before.

This may be useful especially when dealing with a large amount of candles. Using references instead of objects as it may boost performance.

So for example, the original did without the "in" keyword:

public class ExponentialMovingAverage : ExponentialMovingAverage<IOhlcv, AnalyzableTick<decimal?>>
    {
        public ExponentialMovingAverage(in IEnumerable<IOhlcv> inputs, int periodCount)
            : base(inputs, i => i.Close, periodCount)
        {
        }
    }

The "in" keyword ensures that the function uses a reference to the actual IEnumerable object, but cannot modify the reference. The original code actually makes a copy of that IEnumerable.

https://dotnetcoretutorials.com/2018/01/08/new-keyword-c-7-2/

@irperez
Copy link
Collaborator Author

irperez commented Sep 15, 2018

Just realized that variables that have the "in" keyword assigned are not allowed to be used by LINQ queries...

@karlwancl
Copy link
Owner

Could you elaborate more, or is there any reference on that? Because i have just moved the compiler version to "latest" (latest is 7.3 I suppose), and have tested marking an "in" keyword for inputs in AnalyzableBase class, and the test case runs properly without any issue.

@irperez
Copy link
Collaborator Author

irperez commented Sep 16, 2018

If that's the case than it works in some situations and may not work for in others. We may have to learn the rules around "in". Compiler complained when put "in" with a function that used that parameter within a LINQ statement.

We just need to be sure that any use of "in", there really is no modification of that objection. It's just for reading. And we need to be very careful of using "in" on structs as that can slow things down.

@karlwancl
Copy link
Owner

yea, i agree. We must make sure the suitable use cases of "in" parameter first before we proceed the change. And for the case you've mentioned, could you branch an un-workable version for me to investigate the problem, i mean the "not allowed to be used by LINQ" use case.

@alikalfaoglu
Copy link

alikalfaoglu commented Feb 20, 2020

Suitable for value types only. Objects are already passed as byref.

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

3 participants