narrow-branch-50331
12/21/2021, 9:57 PMgentle-yak-5792
12/21/2021, 9:57 PMstraight-dentist-91146
12/22/2021, 9:45 PMproud-chef-46484
12/22/2021, 9:45 PMbitter-easter-52480
01/05/2022, 3:37 PMbitter-easter-52480
01/05/2022, 3:37 PMrough-tent-89243
01/07/2022, 6:34 AMclass Person:
def _init_(name, dob, ...) {
self.name = name
self.dob = dob
....
self.is_stale = True
self.object_size = self.is_stale
}
def update_name(self, ...) {
...
self.is_stale = True
}
def update_dob(self, ...) {
...
self.is_stale = True
}
`@Property
def is_stale() # check stale and re-calcualte the size
Now, what I want is if any field gets updated then is_stale should trigger and update the object_size with the new value.
Is there are way to introduce observer pattern here? Also, how to minimize the re-calcualtion?fierce-waitress-97005
01/10/2022, 1:47 AMrich-needle-6822
01/25/2022, 2:04 AMnarrow-branch-50331
02/04/2022, 8:08 PMboundless-flag-89582
02/04/2022, 8:08 PMfuture-cpu-61076
02/11/2022, 10:20 AMcold-pencil-49545
02/19/2022, 2:26 AMbroad-minister-27322
02/26/2022, 10:07 PMbland-nightfall-55487
02/26/2022, 10:14 PMhttps://1fykyq3mdn5r21tpna3wkdyi-wpengine.netdna-ssl.com/wp-content/uploads/2017/12/Figure-3-768x892.png▾
broad-minister-27322
02/27/2022, 8:46 AMgray-river-93800
03/09/2022, 3:37 AMminiature-autumn-70486
03/20/2022, 12:15 PM"""First code"""
arr = [[] for i in range(2)]
arr[0].append(5)
print(arr)
# Output: [[5], []]
"""Second code"""
arr = [[None]]*2
arr[0].append(5)
print(arr)
# Output: [[None, 5], [None, 5]]
cuddly-telephone-85993
03/28/2022, 2:00 PMrich-needle-6822
04/06/2022, 10:52 PMenough-knife-22652
04/07/2022, 9:10 AMrich-needle-6822
04/17/2022, 9:53 AMadamant-pilot-27287
04/24/2022, 2:57 AMfaint-france-53569
04/30/2022, 3:36 PMmagnificent-school-45641
08/18/2022, 1:44 PMmagnificent-school-45641
08/20/2022, 6:42 AMdelightful-airplane-21117
08/25/2022, 4:22 AMbumpy-manchester-70989
11/01/2022, 12:06 PMflat-bear-74096
12/09/2022, 3:53 AMfew-air-81505
01/20/2023, 11:14 AM