junrushao commented on code in PR #380:
URL: https://github.com/apache/tvm-ffi/pull/380#discussion_r2659984152
##########
python/tvm_ffi/container.py:
##########
@@ -192,6 +192,10 @@ def __contains__(self, value: object) -> bool:
"""Check if the array contains a value."""
return _ffi_api.ArrayContains(self, value)
+ def __bool__(self) -> bool:
+ """Return True if the array is non-empty."""
+ return self.__chandle__() != 0 and len(self) > 0
Review Comment:
I don't think there's a need to check `__chandle__()`
```suggestion
return len(self) > 0
```
##########
python/tvm_ffi/container.py:
##########
@@ -337,6 +341,10 @@ def __len__(self) -> int:
"""Return the number of items in the map."""
return _ffi_api.MapSize(self)
+ def __bool__(self) -> bool:
+ """Return True if the map is non-empty."""
+ return self.__chandle__() != 0 and len(self) > 0
Review Comment:
ditto
--
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]