1. Ronald Oussoren
  2. pyobjc

Issues

Issue #12 duplicate

objc.addConvenienceForSelector must go

Ronald Oussoren
repo owner created an issue

objc.addConvenienceForSelector and the dictionary objc._convenience.CONVENIENCE_METHODS that is used by this function can only work when a class is fully initialized when it is first accessed (that is the method table of the class must be scanned and proxies must be generated for all methods).

Keeping the scanned method table up to date is very expensive and should be replaced by an implementation that only looks for methods that are actually used (possibly with a negative cache for methods that are not found, but that requires care because of dynamically loadable categories).

Steps:

  • No longer use CONVENIENCE_METHODS in pyobjc-core (and subprojects), replace this by use of CLASS_METHODS. I've started work on a script that reports which convenience methods are added to classes.

  • Rename CONVENIENCE_METHODS to _CONVENIENCE_METHODS, and deprecate addConvenienceForSelector.

  • Do a release with these changes

  • Remove addConvenienceForSelector (and the dict)

  • Change pyobjc-core to not perform a full method table scan, add implementation of dir for introspection

It might be possible to do this before the next release when addConvenienceForSelector can continue to work correctly in this implementation (even if that would have a cost). One way to do this would be to perform a full scan when PyObjC detects that the CONVENIENCE_METHODS dict is not empty.

Comments (1)

  1. Log in to comment