Skip to content

Fix the WASM build #701

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

Merged
merged 4 commits into from
Mar 21, 2019
Merged

Fix the WASM build #701

merged 4 commits into from
Mar 21, 2019

Conversation

coolreader18
Copy link
Member

@coolreader18 coolreader18 commented Mar 20, 2019

For some reason it was panicking when trying to import json.{dumps,loads}, so I just switched to using plain rust functions straight from json.rs.

@@ -188,31 +188,31 @@ impl<'de> Visitor<'de> for PyObjectDeserializer<'de> {
}
}

pub fn ser_pyobject(vm: &mut VirtualMachine, obj: &PyObjectRef) -> serde_json::Result<String> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not expose functions like this. I would prefer to figure out what went wrong, and fix that instead.

Copy link
Member Author

@coolreader18 coolreader18 Mar 20, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about as a method on VM? json could be a pub(crate) mod and it wouldn't really be exposed. The code would also be faster because it's not looking up a function and loading it from a module, it's just calling a Rust function.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really agree with @windelbouwman here - this isn't an implementation detail, it's the actual python function so it's inevitable to expose these at some point to allow developing native extensions without unnecessary overhead.

The code would also be faster because it's not looking up a function and loading it from a module, it's just calling a Rust function.

Yep! 👍

@@ -1,6 +1,6 @@
mod ast;
mod dis;
mod json;
pub mod json;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep this code private. Having this code unexposed is a good thing, and avoids leaking internals.

@coolreader18
Copy link
Member Author

I am going to merge this just in order to stop the CI builds from failing, but I feel like the VM methods are a good compromise for concerns regarding leaking internals.

@coolreader18 coolreader18 merged commit f5bbc7f into master Mar 21, 2019
@coolreader18 coolreader18 deleted the coolreader18/fix-wasm-import-json branch March 21, 2019 22:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants