code: def run():
      t = CustomObjectStore(1)
      t2 = CustomObjectStore(2)
  
      assert sys.getrefcount(t) == 2
      assert sys.getrefcount(t2) == 2
  
      data = {"a": [0], "b": [t]}
      assert sys.getrefcount(t) == 3
  
      tbl = Table(data, index="a")
      assert sys.getrefcount(t) == 4
  
      assert tbl.schema() == {"a": int, "b": object}
      assert tbl.size() == 1
      assert tbl.view().to_dict() == {"a": [0], "b": [t]}
  
      # Count references
      # 1 for `t`, 1 for `data`, 1 for argument to sys.getrefcount, and 1 for the table
      print(sys.getrefcount(t), "should be", 4)
      print("t:", id(t))
      assert sys.getrefcount(t) == 4
  
      print(sys.getrefcount(t2), "should be", 2)
      print("t2:", id(t2))
      assert sys.getrefcount(t2) == 2
  
      tbl.update([{"a": i, "b": None} for i in range(1, 6)])
  
      assert tbl.size() == 6
      # 1 for `t`, 1 for `data`, 1 for argument to sys.getrefcount, and 1 for the table
      print(sys.getrefcount(t), "should be", 4)
      assert sys.getrefcount(t) == 4
  
      print()
      tbl.update([data])
      # 1 for `t`, 1 for `data`, 1 for argument to sys.getrefcount, and 1 for the table
      print(sys.getrefcount(t), "should be", 4)
      assert sys.getrefcount(t) == 4
  
      print()
      tbl.update([data])
      # 1 for `t`, 1 for `data`, 1 for argument to sys.getrefcount, and 1 for the table
      print(sys.getrefcount(t), "should be", 4)
      assert sys.getrefcount(t) == 4
  
      print()
      tbl.update([data])
      # 1 for `t`, 1 for `data`, 1 for argument to sys.getrefcount, and 1 for the table
      print(sys.getrefcount(t), "should be", 4)
      assert sys.getrefcount(t) == 4
  
      print()
      tbl.update([{"a": 1, "b": t}])
      # 1 for `t`, 1 for `data`, 1 for argument to sys.getrefcount, and 2 for the table
      print(sys.getrefcount(t), "should be", 5)
      assert sys.getrefcount(t) == 5
  
      print()
      tbl.update([{"a": 1, "b": t}])
      # 1 for `t`, 1 for `data`, 1 for argument to sys.getrefcount, and 2 for the table
      print(sys.getrefcount(t), "should be", 5)
      assert sys.getrefcount(t) == 5
  
      print()
      tbl.update([{"a": 3, "b": t}])
      # 1 for `t`, 1 for `data`, 1 for argument to sys.getrefcount, and 3 for the table
      print(sys.getrefcount(t), "should be", 6)
      assert sys.getrefcount(t) == 6
  
      print()
      tbl.update([{"a": 3, "b": t}])
      # 1 for `t`, 1 for `data`, 1 for argument to sys.getrefcount, and 3 for the table
      print(sys.getrefcount(t), "should be", 6)
      assert sys.getrefcount(t) == 6
  
      print()
      tbl.update([{"a": 5, "b": t}])
      # 1 for `t`, 1 for `data`, 1 for argument to sys.getrefcount, and 4for the table
      print(sys.getrefcount(t), "should be", 7)
      # assert sys.getrefcount(t) == 7
      print(tbl.view().to_dict()["b"])
      assert list(_ is not None for _ in tbl.view().to_dict()["b"]) == [
          True,
          True,
          False,
          True,
          False,
          True,
      ]
  
      print()
      # clear some, overwrite some with same
      tbl.update([{"a": 0, "b": t}])
      # 1 for `t`, 1 for `data`, 1 for argument to sys.getrefcount, and 4 for the table
      print(sys.getrefcount(t), "should be", 7)
      assert list(_ is not None for _ in tbl.view().to_dict()["b"]) == [
          True,
          True,
          False,
          True,
          False,
          True,
      ]
  
      print()
      tbl.update([{"a": 1, "b": t2}])
      # 1 for `t`, 1 for `data`, 1 for argument to sys.getrefcount, and 3 for the table
      print(sys.getrefcount(t), "should be", 6)
      # 1 for `t2`, 1 for argument to sys.getrefcount, and 1 for the table
      print(sys.getrefcount(t2), "should be", 3)
      print(tbl.view().to_dict()["b"])
      assert list(_ is not None for _ in tbl.view().to_dict()["b"]) == [
          True,
          True,
          False,
          True,
          False,
          True,
      ]
  
      print()
      tbl.update([{"a": 1, "b": t2}])
      # 1 for `t`, 1 for `data`, 1 for argument to sys.getrefcount, and 3 for the table
      print(sys.getrefcount(t), "should be", 6)
      # 1 for `t2`, 1 for argument to sys.getrefcount, and 1 for the table
      print(sys.getrefcount(t2), "should be", 3)
      print(tbl.view().to_dict()["b"])
      assert list(_ is not None for _ in tbl.view().to_dict()["b"]) == [
          True,
          True,
          False,
          True,
          False,
          True,
      ]
  
      print()
      tbl.update([{"a": 1, "b": t2}])
      # 1 for `t`, 1 for `data`, 1 for argument to sys.getrefcount, and 3 for the table
      print(sys.getrefcount(t), "should be", 6)
      # 1 for `t2`, 1 for argument to sys.getrefcount, and 1 for the table
      print(sys.getrefcount(t2), "should be", 3)
      print(tbl.view().to_dict()["b"])
      assert list(_ is not None for _ in tbl.view().to_dict()["b"]) == [
          True,
          True,
          False,
          True,
          False,
          True,
      ]
  
      print()
      tbl.update([{"a": 1, "b": t2}])
      # 1 for `t`, 1 for `data`, 1 for argument to sys.getrefcount, and 3 for the table
      print(sys.getrefcount(t), "should be", 6)
      # 1 for `t2`, 1 for argument to sys.getrefcount, and 1 for the table
      print(sys.getrefcount(t2), "should be", 3)
      print(tbl.view().to_dict()["b"])
      assert list(_ is not None for _ in tbl.view().to_dict()["b"]) == [
          True,
          True,
          False,
          True,
          False,
          True,
      ]
  
      print()
      tbl.update([{"a": 2, "b": t2}])
      # 1 for `t`, 1 for `data`, 1 for argument to sys.getrefcount, and 3 for the table
      print(sys.getrefcount(t), "should be", 6)
      # 1 for `t2`, 1 for argument to sys.getrefcount, and 1 for the table
      print(sys.getrefcount(t2), "should be", 4)
      print(tbl.view().to_dict()["b"])
      assert list(_ is not None for _ in tbl.view().to_dict()["b"]) == [
          True,
          True,
          True,
          True,
          False,
          True,
      ]
  
      print()
      tbl.update([{"a": 2, "b": None}])
      # 1 for `t`, 1 for `data`, 1 for argument to sys.getrefcount, and 3 for the table
      print(sys.getrefcount(t), "should be", 6)
      # 1 for `t2`, 1 for argument to sys.getrefcount, and 1 for the table
      print(sys.getrefcount(t2), "should be", 3)
      print(tbl.view().to_dict()["b"])
      assert list(_ is not None for _ in tbl.view().to_dict()["b"]) == [
          True,
          True,
          False,
          True,
          False,
          True,
      ]
  
      print()
      tbl.update([{"a": 2, "b": t2}])
      # 1 for `t`, 1 for `data`, 1 for argument to sys.getrefcount, and 3 for the table
      print(sys.getrefcount(t), "should be", 6)
      # 1 for `t2`, 1 for argument to sys.getrefcount, and 1 for the table
      print(sys.getrefcount(t2), "should be", 4)
      print(tbl.view().to_dict()["b"])
      assert list(_ is not None for _ in tbl.view().to_dict()["b"]) == [
          True,
          True,
          True,
          True,
          False,
          True,
      ]
  
      print()
      tbl.update([{"a": 2, "b": None}])
      # 1 for `t`, 1 for `data`, 1 for argument to sys.getrefcount, and 3 for the table
      print(sys.getrefcount(t), "should be", 6)
      # 1 for `t2`, 1 for argument to sys.getrefcount, and 1 for the table
      print(sys.getrefcount(t2), "should be", 3)
      print(tbl.view().to_dict()["b"])
      assert list(_ is not None for _ in tbl.view().to_dict()["b"]) == [
          True,
          True,
          False,
          True,
          False,
          True,
      ]
  
      print()
      tbl.update([{"a": 3, "b": None}])
      # 1 for `t`, 1 for `data`, 1 for argument to sys.getrefcount, and 2 for the table
      print(sys.getrefcount(t), "should be", 5)
      # 1 for `t2`, 1 for argument to sys.getrefcount, and 1 for the table
      print(sys.getrefcount(t2), "should be", 3)
      print(tbl.view().to_dict()["b"])
      assert list(_ is not None for _ in tbl.view().to_dict()["b"]) == [
          True,
          True,
          False,
          False,
          False,
          True,
      ]
  
      print()
      tbl.update([{"a": 3, "b": None}])
      # 1 for `t`, 1 for `data`, 1 for argument to sys.getrefcount, and 2 for the table
      print(sys.getrefcount(t), "should be", 5)
      # 1 for `t2`, 1 for argument to sys.getrefcount, and 1 for the table
      print(sys.getrefcount(t2), "should be", 3)
      print(tbl.view().to_dict()["b"])
      assert list(_ is not None for _ in tbl.view().to_dict()["b"]) == [
          True,
          True,
          False,
          False,
          False,
          True,
      ]
  
      print()
      tbl.update([{"a": 5, "b": None}])
      # 1 for `t`, 1 for `data`, 1 for argument to sys.getrefcount, and 1 for the table
      print(sys.getrefcount(t), "should be", 4)
      # 1 for `t2`, 1 for argument to sys.getrefcount, and 1 for the table
      print(sys.getrefcount(t2), "should be", 3)
      print(tbl.view().to_dict()["b"])
      assert list(_ is not None for _ in tbl.view().to_dict()["b"]) == [
          True,
          True,
          False,
          False,
          False,
          False,
      ]
  
      print()
      tbl.update([{"a": 5, "b": None}])
      # 1 for `t`, 1 for `data`, 1 for argument to sys.getrefcount, and 1 for the table
      print(sys.getrefcount(t), "should be", 4)
      # 1 for `t2`, 1 for argument to sys.getrefcount, and 1 for the table
      print(sys.getrefcount(t2), "should be", 3)
      print(tbl.view().to_dict()["b"])
      assert list(_ is not None for _ in tbl.view().to_dict()["b"]) == [
          True,
          True,
          False,
          False,
          False,
          False,
      ]
  
      print()
      tbl.clear()
      assert tbl.size() == 0
      assert tbl.view().to_dict() == {}
      # 1 for `t`, one for `data`, one for argument to sys.getrefcount
      print(sys.getrefcount(t), "should be", 3)
      assert sys.getrefcount(t) == 3
  
file_path: perspective/python/perspective/perspective/tests/table/object_sequence.py
imports: import sys
  from random import randint, choice
  from perspective.table import Table
label_desc: Use image node_id 1 for calling a global function with example usage: run() without return types