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

Unexplained slowness of method 'Invoke' of 'PyIDispatch' objects #102

Open
airguru opened this issue May 29, 2024 · 1 comment
Open

Unexplained slowness of method 'Invoke' of 'PyIDispatch' objects #102

airguru opened this issue May 29, 2024 · 1 comment

Comments

@airguru
Copy link
Contributor

airguru commented May 29, 2024

Hello,

I have succesfully written a fairly complex library and it works fine on almost all machines that I have deployed it so far. These had different hardware, operating system versions, Excel versions, antivirus softwares, security configurations etc.

However, on one specific machine, which is almost the most HW performant of them all, one of my macros performs very slow. It involves some spreadsheet cell modification within PauseExcel() block. In profiler, I see that most of the time is spent during: ~:0(<method 'Invoke' of 'PyIDispatch' objects>), where a total of 18 calls are performed, with 0.2s per call for a total of 3.7s (95% of total execution time). In all other environments so far this is not a problem at all and is at least 5-10x faster.

I have compared everything I could between my and target environment, and could not find any meaningful difference. This is on xloil 0.18.6.

Do you have any idea what could be the source of the issues, where to even start looking?

Thanks in advance.

@cunnane
Copy link
Owner

cunnane commented Jul 7, 2024

Sorry, missed a reply here. PyIDispatch is part of win32com so outside of xlOil, so I can see a few things to try:

  1. As far as possible, disable security software and remove other Excel addins to eliminate effects from these
  2. If possible, alter the macro to avoid using calls through win32com (properties/methods with CamelCase) and prefer using xlOil accessors (properties/methods with snake_case). If the methods you need don't exist in xlOil I can look at adding them.
  3. Consider surrounding the code with xloil.events.pause() and xloil.events.allow(). This stops xlOil's event mechanism, whereas PauseExcel suppress's Excel's events. I think this is unlikely to work, but is easy to try.

Let me know how this goes!

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

2 participants