On Tue, 15 Sep 2015 01:10 am, Random832 wrote: > On Mon, Sep 14, 2015, at 10:48, Akira Li wrote: >> start, stop, step attributes (corresponding Python ints) may not exist >> ("the objects we've talking about have never been created") until you >> request them explicitly. > > That's not true in CPython. In fact, the range object in python contains > *four* reference boxes - one more for length.
I really don't see why any of this is relevant to the business being discussed. A range object is an object. It has an interface, e.g. it is sized (has a length), it has start, stop and step attributes. But the *implementation* of that interface is (1) irrelevant and (2) subject to change. Maybe the __len__ method calculates the length on the fly. Maybe start, stop and step are virtual attributes that extract the appropriate values from a C-level datastructure inaccessible to pure Python code. Unless you are the author of the range class, you don't really have any business worrying about whether range.start is a "reference" to the start value, or something computed on the fly as needed. It could be either. -- Steven -- https://mail.python.org/mailman/listinfo/python-list