py_scope is mostly immutable.

Either it's always None, or it is set once to something non-None and then not
changed.
Use various hints to speed up referencing PHP objects from Python.

On Richards, this leads to a roughly 25% performance increase.