Martin explanation is correct. [Martin v. Loewis] > You can do it like this: > > map = {} > > def wrap(java.lang.Object o): > try: > return map[o] > except KeyError: > map[o] = res = wrapper(o, new_id()) > return res > > That requires a map lookup every time a wrapper is created; clearly > undesirable. I think Samuele had something in mind like: > With this approach you could use less memory if there is much wrapper duplication, but typically a Java object does not get many long-lived different wrappers. This "wrap" is quite a core operation, and the map need to be weak otherwise you leak badly. That means that you can implement it only with java >1.2 and anyway weak-dictionaries in java require dealing with polling queues of reset weak-refs. This means complication and slowdown where we would prefer to avoid it. regards.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4