Use WeakMap for hashing objects if available