Skip to content

Fall back from gen_py to dynamic COM client class & fix property ID caching#1931

Draft
kxrob wants to merge 3 commits intomhammond:mainfrom
kxrob:_com_genXdyn
Draft

Fall back from gen_py to dynamic COM client class & fix property ID caching#1931
kxrob wants to merge 3 commits intomhammond:mainfrom
kxrob:_com_genXdyn

Conversation

@kxrob
Copy link
Copy Markdown
Collaborator

@kxrob kxrob commented Aug 18, 2022

Necessary e.g. for the WMI scripting library

kxrob added 2 commits August 18, 2022 11:45
COM object properties which are not found by
__LazyMap__() / PyITypeComp.Bind(), but only by
__AttrToID__() / GetIDsOfNames() were not ID-cached
and caused time consuming search upon every read.
.. when type info may be incomplete.

Example "Microsoft WMI Scripting Library": This failed
before when pre-compiled in win32com.gen_py:

    WMI = win32com.client.GetObject('winmgmts:')
    processes = WMI.InstancesOf('Win32_Process')
    processes.ItemIndex(0).Name
@mhammond
Copy link
Copy Markdown
Owner

This is a fairly simple change which is great! It's still a WIP so it's not clear what else you intend doing, but given you mention WMI it would be fantastic if some tests which demonstrate the improvements could be added.

retEntry = self._olerepr_.propMapGet.get(attr)
if retEntry is None:
retEntry = build.MapEntry(self.__AttrToID__(attr), (attr,))
self._olerepr_.propMap[attr] = retEntry
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I've extracted this change to #2750

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

Successfully merging this pull request may close these issues.

3 participants