-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Track patients with unordered_set rather than vector #1253
base: master
Are you sure you want to change the base?
Conversation
The stored vector of pybind-registered-type patients can grow without bound if a function is called with the same patient multiple times. This commit changes the pybind internal patient storage to an `unordered_set` to avoid the issue. Fixes pybind#1251
Hi @jagerman -- sorry for not getting to this (now-ancient PR) earlier. This is just to say that your change looks good to me. We could merge it to master and consider it for inclusion to the next minor version. Would you be able to address the conflicts? |
…patient-constraint
I'm briefly trying to see if I can update this PR, resolving merge conflicts, per discussion in #1251. (For now, will do fast-forward merge) |
- Checks `not m.has_patients()` after nurse is gc'd - Uses Python implementation of `refcount`
This fixes pybind#1251 (patient vector grows without bounds) for the 2.2.2 branch by checking that the vector doesn't already have the given patient. This is a little less elegant than the same fix for `master` in pybind#1253 (which changes the patients `vector` to an `unordered_set`), but that requires an internals layout change, which this approach avoids.
Filed #2289 per @YannickJadoul's request: My pref is on this PR, if we think it'll be more efficient. |
Same thing as before: depends on whether/when we want to break the internal ABI ;-) |
The stored vector of pybind-registered-type patients can grow without
bound if a function is called with the same patient multiple times.
This commit changes the pybind internal patient storage to an
unordered_set
to avoid the issue.Fixes #1251
I've also pushed a separate fix for 2.2.2 (in #1250) that solves this by walking through the vector to avoid storing a duplicate. (It's not as nice a fix, but it doesn't require changing the
internals
structure for 2.2.2).EDIT(eric): #2289 is an alternative or precursor to this PR.