DOC: Explain why _BoundColumnDescr exists.

We don't want to bind to parent DataSets when we bind to names because
we want to dynamically create new BoundColumns in subclasses.
This commit is contained in:
Scott Sanderson
2016-02-12 21:21:19 -05:00
parent 1bf33f9ee0
commit 9c448b5238
+9
View File
@@ -33,12 +33,21 @@ class _BoundColumnDescr(object):
"""
Intermediate class that sits on `DataSet` objects and returns memoized
`BoundColumn` objects when requested.
This exists so that subclasses of DataSets don't share columns with their
parent classes.
"""
def __init__(self, dtype, name):
self.dtype = dtype
self.name = name
def __get__(self, instance, owner):
"""
Produce a concrete BoundColumn object when accessed.
We don't bind to datasets at class creation time so that subclasses of
DataSets produce different BoundColumns.
"""
return BoundColumn(
dtype=self.dtype,
dataset=owner,