kurisu6912 opened a new issue, #326:
URL: https://github.com/apache/tvm-ffi/issues/326
On the Python side, `Map.get` has a large overhead when the key is missing.
```py
def check_and_get_(mp, key, default):
return mp[key] if key in mp else default
```
```
Map.get 35131.5678 (ns)
check and get 360.2804 (ns)
```
This is because the `Map.get` uses `try ... except ...` in the path. When
the key is missing, it falls back to python error handing pipeline, which is
very costful.
https://github.com/apache/tvm-ffi/blob/f7e09d6a96b54554190bae0d7ba9ff7a6e9a109e/python/tvm_ffi/container.py#L335-L355
I think we should refactor it to check inside for better performance
```py
def get(self, key: K, default: V | _DefaultT | None = None) -> V | _DefaultT
| None:
return self[key] if key in self else default
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]