-
-
Notifications
You must be signed in to change notification settings - Fork 181
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
dump_session: add split_imports #101
Conversation
Example:
Loading - no surprises here:
|
This needs a better name than 'split_imports', I think, given that it ends up discarding most or all of the state of non-main modules. Works very well for the way I use IPython, but it's a substantial change in behaviour. |
@abrasive: Hmm.. thanks. This looks nice. @matsjoyce: We broached this question in #66, but did not implement anything as a follow-up. |
Well, the |
I'm targeting a new release for end of June, and would like to get this and #86 and #100 sorted for it. I'll go about tagging issues soon, but if you don't think this would interfere with |
@abrasive: I've reviewed this, and will accept it once any issues in this ticket are sorted out. Could you make these mods?
I will likely rename the four helper functions, but they are fine as is for the moment. |
@matsjoyce: I might consider enabling this in general, not just for |
@matsjoyce: I think this can work semi-independely of #43 (and thus #47). It doesn't seem to remove any functionality as far as I can tell. Nothing I have tried fails with it and not without it, but if you can think of a failure case that does, let me know. It would have to be something like edits to imported objects being lost on dump_session. |
I take that back... It does appear it would remove some functionality, in roughly how I expected. If you import a pure python module and change it's |
Amended as requested. I think having the parameter named 'byref' makes sense logically, but dump_session also deals with '_byref' which is confusing. I'll leave that up to you. |
@abrasive: Thanks, and true… but |
@abrasive: I was thinking something more like this, as it would allow iterators to be used for
Would you mind? Then I can just pull and not have to edit it. |
OK, done. |
Setting byref=True will preprocess the module by groveling through its top-level objects for things that are identical to those in the other available modules. If it finds matches, it records the names and discards the objects during pickling. On load, it then recovers the objects by "import x as y" using the stored x, y. This fixes issues with nasty unpickleable things in the depths of libraries, as well as making the sessions smaller. Fixes #79 and most of #78.
dump_session: add split_imports
brilliant. |
Setting split_imports=True will preprocess the module by groveling
through its top-level objects for things that are identical to those in
the other available modules. If it finds matches, it records the source
module and object names and then discards the objects during pickling.
On load, it then recovers the objects by "import x as y" using the
stored x, y.
This fixes issues with nasty unpickleable things in the depths of
libraries, as well as making the sessions smaller.
Fixes #79 and most of #78 - my pylab sessions start up with some dynamic GObject horribles in
__main__
.