As discussed in this Pull Request,
inspect.getmembers will call properties and other dynamic attributes, as it is using the
getattr method. I proposed changing this to
getattr_static, however, this will break compatibility with existing code.
Yury Selivanov (1st1) proposed to implement a
getmembers_static function instead, that will use
getattr_static. However, there are still many open questions:
- What should
getattr_staticappropriate for every member? This would break some predicates (e.g.
isclass, see comment above). There does not seem to be a “simple” solution.
- A technical question: The new method should pass most of the same tests as
getmembers. Would one just copy and paste the old ones? It would also share most of the code - except for maybe 1 line - with
- Is there a reason for
getmembersto return a list of tuples? I would have suggested to use a
dictinstead, which feels more intuitive on first though.
- Why should getmembers return the value of the member (
Any suggestions or ideas?