-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Pickle compatible for replay buffer and improve buffer.get #182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: youkaichao <youkaichao@gmail.com>
Do you guys have any tutorial on what exactly do |
Hum strange, I found the online Python documentation about Pickle quite well written. |
Oh yes, I didn't notice this section. After reading it, everything is crystal clear. |
Okay, so far there are 2 solutions to resolve this issue. The main issue is: The first is to write The second is to add a def __getattr__(self, key):
if '_meta' not in self.__dict__:
raise AttributeError
try:
return self._meta[key]
except KeyError:
return AttributeError But this will cause another overhead, though it doesn't need to rewrite the set/getattr. What's your opinion @duburcqa @youkaichao |
I vote for this, the pythonic way to do it. Pickling buffer does not work out of box because the customized behavior of |
I think this is actually a stupid behavior of python. Why the hell does it invoke |
Why would it be more pythonic ? I also think it is more logical to override the pickle interface, or at least part of it, since it more directly solve the problème your are facing. |
By "pythonic", I mean, do what python wants us to do, since python leaves these interfaces to achieve pickle. |
I don't agree. Those interfaces have been designed to allow implementing much more complex behavior than one liners with default behavior except for a single attribute. So it is not clear to me if it is more appropriate to adapt the code to make the default work, or define custom interface, making pickle behavior less predictable for the user without reading the code. Modifying the behavior of standard methods is almost always at last resort for me. |
Okay, I withdraw the word "pythonic". Just because pickling buffer does not work out of box( |
Codecov Report
@@ Coverage Diff @@
## dev #182 +/- ##
==========================================
+ Coverage 89.16% 89.25% +0.09%
==========================================
Files 39 39
Lines 2391 2402 +11
==========================================
+ Hits 2132 2144 +12
+ Misses 259 258 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
Maybe it would be safe to wait one week or so before releasing it, just in case there is still a few bugs around. But I think the features are there. |
fix thu-ml#84 and make buffer more efficient
fix #84 and make buffer more efficient