plone.api.portal get the portal walking the path until it find ISiteRoot instead of using getMultiAdapter. The call is not cached but the portal object cannot change inside a DX Root Object. Could this cached with @forever.memoize? Generally speaking, could we cache the portal somewhere? What is the best way to get the portal object? The plone_portal_state view cache it (@memoize) it but to get the view we still have to do a traverse.
in my addon but seems too much to me. I mean, getMultiAdapter query a zope object which, starting from context and request, search for a suitabile interface implementer (IPortalState). Is this quite fast or it is better to cache it? I would cache it forever (but for Plone Site) but maybe there are cases where getting the portal must return None?
I think it is relative fast (even if thread local variables are not that fast to access). Getting the site manager to lookup adapters does the same in the process, so the pure direct access is probably faster.
Is this because every thread run on a single request (request url -> traversal -> site set)? This means the site thread local variable is set at every request, then used by the python code.