-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Add string interning #2325
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
Add string interning #2325
Conversation
Ah, crap, I meant to make the rustpython_bytecode::bytecode flattening a separate commit, one sec |
039086c
to
3fc525d
Compare
2448976
to
9fa7014
Compare
Alright, this is good for review now |
9fa7014
to
2f232ec
Compare
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.
Would you explain a bit about PyStrExact?
I am curious how it works in CPython and how they make benefits in RustPython comparing to bare PyStr.
@@ -172,37 +181,39 @@ pub enum ConversionFlag { | |||
Repr, | |||
} | |||
|
|||
pub type NameIdx = usize; |
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.
is this intended to be used with arithmatic operations? otherwise, I think struct(usize)
would be better.
bytecode::BorrowedConstant::Str { value } if value.len() <= 20 => { | ||
vm.intern_string(value).into_object() | ||
} | ||
bytecode::BorrowedConstant::Str { value } => vm.ctx.new_str(value), |
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.
Does constant interning also affect by string length?
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.
Oh, I think I confused it with this, it should be interned still
Yeah, so it's a lot easier to deal with interning if you know that everything in the dict is a strict |
./rustpython-norm benchmarks/pystone.py 500000
./rustpython-opt benchmarks/pystone.py 500000