Skip to content

Conversation

@jhonabreul
Copy link
Collaborator

@jhonabreuljhonabreul commented Aug 13, 2025

Refactor enums comparison operators for performance improvements.
Introduce new EnumObject class to handle managed enums and their comparison operations.

Performance test:

publicvoidPerformanceTest(){usingvar_=Py.GIL();usingvarmodule=PyModule.FromString("PerformanceTest",$@"from System import DayOfWeekdef test(): result = True enum_value = DayOfWeek.MONDAY for _ in range(500000): result = result and enum_value == DayOfWeek.MONDAY and enum_value != DayOfWeek.FRIDAY return result");varstopwatch=Stopwatch.StartNew();Assert.IsTrue(module.InvokeMethod("test").As<bool>());stopwatch.Stop();Console.WriteLine($"Total time: {stopwatch.Elapsed.TotalSeconds}s");}

Master:

Total time: 18.6504161s Total time: 19.0529056s Total time: 19.0023384s Total time: 18.5928232s Total time: 18.7222117s 

Avg: 18.8s

Branch:

Total time: 0.5745701s Total time: 0.5748509s Total time: 0.5982596s Total time: 0.5831667s Total time: 0.564322s 

Avg: 0.58s

The test is ~32x faster.

@jhonabreuljhonabreul merged commit 1aa5b8b into QuantConnect:masterAug 14, 2025
0 of 21 checks passed
@jhonabreuljhonabreul deleted the refactor-enum-comparison-operators-performance branch August 14, 2025 15:29
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@jhonabreul@Martin-Molinero