Skip to content

Basic json module implementation in rust - #89

Merged
windelbouwman merged 2 commits into
RustPython:masterfrom
OddBloke:json
Aug 26, 2018
Merged

windelbouwman merged 2 commits into
RustPython:masterfrom
OddBloke:json

Conversation

@OddBloke

Copy link
Copy Markdown
Collaborator

This stdlib placement seems OK to me, but if anyone else has an opinion about where we should be placing the Rust parts of our stdlib, I'd be more than happy to follow that.

@windelbouwman

Copy link
Copy Markdown
Contributor

Briljant! This was my idea that this should be relatively easy by using the rust eco system 👍

Comment thread vm/src/import.rs
}

// Check for Rust-native modules
if let Some(module) = stdlib::get_modules(vm).get(module) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

get_modules is now called often, it's return value should be stored in ctx somewhere or in the vm maybe.

Comment thread vm/src/stdlib/json.rs
S: serde::Serializer,
{
match self {
PyObjectKind::String { value } => serializer.serialize_str(value),

@windelbouwman windelbouwman Aug 26, 2018 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Instead of using ObjectKind, use isinstance or alike to check for the type. This allows for subclasses of str, like class MyStr(str) to work as well. We can do this later though..

Comment thread vm/src/stdlib/json.rs

fn visit_str<E>(self, value: &str) -> Result<Self::Value, E>
where
E: serde::de::Error,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Okay, this rust code is above my paygrade 😄

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.

2 participants