-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Remove inner Box from PyObject #671
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
@@ -695,10 +695,10 @@ impl Default for PyContext { | |||
/// This is an actual python object. It consists of a `typ` which is the | |||
/// python class, and carries some rust payload optionally. This rust | |||
/// payload can be a rust float or rust int in case of float and int objects. | |||
pub struct PyObject { | |||
pub struct PyObject<T: ?Sized> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the effect of this template on the code size? Did you check this? This is of interest to the wasm build, since it may be intended for web.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There aren't really any methods on PyObject, so making it generic won't duplicate much code; it's just a container.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could throw some #[inline]
s on PyObject::new and PyObject::into_ref but those are the only ones that are really generic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This increases the binary size by about 2.4% for me, which seems acceptable.
(A side note - moving to the new args style should decrease the binary size because there will only be one monomorphization per distinct function signature, whereas arg_check!
will generate type checking code for each one.)
Conflicts: vm/src/pyobject.rs
cb54c71
to
6025058
Compare
@coolreader18 it looks like something in
|
Ah, you can just put |
Yeah, I already tried that - the problem is that now |
Hmm, you could probably just change |
Are you still working on this? |
Yeah, but merging in master caused an infinite loop in |
Redone in #671 |
(WIP: will need to incorporate changes from #670 and fixup
Debug
/Display
impls)This removes the
Box
insidePyObject
, so that aPyRef
/PyObjectRef
only needs to follow a single pointer (just like cpython).