22# The previous examples only worked in the local region drawn in light
33# green. This example shows how new regions can be created and used.
44#
5- # The `Region()` constructor creates a new region and returns the bridge
5+ # The `Region()` constructor creates a new region and returns its bridge
66# object. The new region is drawn in yellow. Any object in the yellow
7- # rectangle belongs to the region. The trapezoid shape identifies the
7+ # rectangle belongs to the region. The trapezoid shape denotes the
88# bridge object. It displays the following information about the region:
9- # - LRC: The number of incomming references from the local region.
10- # - SBRC: The number of open subregion.
9+ # - LRC: The number of incoming references from the local region. This
10+ # counter tracks references to all objects in the region not
11+ # just the bridge object. See §3.1 for more details.
12+ # - SBRC: The number of open subregions.
1113# - RC: The reference count of the bridge object.
1214r = Region()
1315
14- # Any objects assigned to the bridge object or an object in the region
16+ # Any objects reachable from the bridge or an object in the region
1517# will automatically be part of the region. Notice how the new dictionaries
1618# are members of the region, indicated by them being in the same yellow box.
1719r.field = {}
@@ -22,23 +24,24 @@ r.field.data = {}
2224r.field.bridge = r
2325r.field.data.parent = r.field
2426
25- # All objects are by default created in the local region.
27+ # All objects are by created in the local region.
2628x = {}
2729x.data = {}
2830
29- # When a region references an object in the local region, it takes ownership of the
30- # object. All referenced objects are also moved into the region. Figure 7 in the paper
31- # shows the individual steps of this process.
31+ # An object in the local region is moved into a region, when an object in the
32+ # region references it. All reachable objects from the moved object are also
33+ # moved into the region. Figure 7 in the paper shows the individual steps of
34+ # this process.
3235r.x = x
3336
34- # Moving the value of `x` into the region increased the LRC since the variable x
35- # is a reference from the local frame into the region. Setting x to `None` will
36- # decrement the LRC again.
37+ # Moving the value of `x` into the region increased the LRC since the variable `x`
38+ # is a reference from the local frame into the region. Reassigning `x` to another
39+ # value will decrement the LRC again. This is done by a write barrier, discussed in
40+ # §3.2 of the paper.
3741x = None
3842
39- # References from within a region are allowed to reference frozen objects. This
40- # is safe since frozen objects don't have an owner and can be safely shared across
41- # threads.
43+ # References to frozen objects are unrestricted. Table 1 in the paper provides a
44+ # good overview of what references are allowed.
4245r.x.data = None
4346
4447# When a region has no incoming references it and all contained objects can
0 commit comments