-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Allow stdlib freeze #1159
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
Allow stdlib freeze #1159
Conversation
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.
LGTM. An idea for allowing specifying the stdlib dir, you could maybe allow a DirFromEnv
CompilationSourceKind
?
derive/src/compile_bytecode.rs
Outdated
|
||
fn compile_dir( | ||
&self, | ||
path: &PathBuf, |
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.
path: &PathBuf, | |
path: &Path, |
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.
Why is this better?
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.
PathBuf
vs Path
is akin to String
vs str
- an owned, allocated buffer vs a slice. Like you should (almost) always prefer &str
over &String
, so should you for &Path
over &PathBuf
.
|
||
let output = quote! { | ||
({ | ||
use ::rustpython_vm::__exports::bincode; | ||
bincode::deserialize::<::rustpython_vm::bytecode::CodeObject>(#bytes) | ||
.expect("Deserializing CodeObject failed") | ||
hashmap! { |
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.
You should probably add hashmap
to __exports
and use it here.
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 purpose of the __exports
? This is my first time using procedural macro
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.
I think I understand what __exports
do. Added hashmap
Btw, I opened this issue in pyckitup: pickitup247/pyckitup#4 they might be interested in this. |
We should probably add the ability to freeze any directory.
I can get the directory from an environment variable but I hoped for something easier. |
Ah yeah, I think that's the best way to go for configuration, as Rust doesn't have anything like that built in. We've done similar configuration in env variables before, e.g. |
I sorta glazed over this when I reviewed earlier, but I don't think that it should always return a |
I am not sure about that... I prefer that |
As discussed in #1142.
Adding the current
Lib
folder increase the executable by 5MB. I would like to add this to the demo so it will support python stdlib.I wanted to allow specifying the location of the stdlib dir with a compilation flag but could not find out how to do that. @coolreader18 any suggestions?