zero argument member functions versus properties

Ian Kelly ian.g.kelly at gmail.com
Sun Nov 3 09:53:43 CET 2013


On Sun, Nov 3, 2013 at 1:06 AM, Peter Cacioppi <peter.cacioppi at gmail.com> wrote:
> Actually C# is mature enough for this idiom. C# and Python both support getter/setter methods that present as direct attribute access to client code, and thus allow you to refactor the class without breaking backwards compatibility.

It's not as clear-cut as it looks in C#.  Although refactoring the
class in this way doesn't change the API, it does break ABI, which is
significant in an environment where virtually everything is
distributed in binary form.  This happens because a property access
compiled to CIL byte code is transformed into a call to a getter or
setter method, which is a distinct operation from an ordinary
attribute access.  Whereas in Python, an attribute access is just
compiled as an attribute access no matter what the underlying
implementation of that access may end up being at run-time.



More information about the Python-list mailing list