Skip to content

Commit 7d2a7a5

Browse files
authored
Merge pull request RustPython#1169 from RustPython/optimizations1
Add some extra profiling trace points.
2 parents 0e95f51 + 881baf6 commit 7d2a7a5

File tree

17 files changed

+317
-284
lines changed

17 files changed

+317
-284
lines changed

DEVELOPMENT.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,16 @@
22

33
## Code organization
44

5+
- `bytecode/src`: python bytecode representation in rust structures
6+
- `compiler/src`: python compilation to bytecode
57
- `parser/src`: python lexing, parsing and ast
8+
- `Lib`: Carefully selected / copied files from CPython sourcecode. This is
9+
the python side of the standard library.
610
- `vm/src`: python virtual machine
711
- `builtins.rs`: Builtin functions
812
- `compile.rs`: the python compiler from ast to bytecode
913
- `obj`: python builtin types
14+
- `stdlib`: Standard library parts implemented in rust.
1015
- `src`: using the other subcrates to bring rustpython to life.
1116
- `docs`: documentation (work in progress)
1217
- `py_code_object`: CPython bytecode to rustpython bytecode converter (work in
@@ -28,8 +33,7 @@ To test rustpython, there is a collection of python snippets located in the
2833

2934
```shell
3035
$ cd tests
31-
$ pipenv install
32-
$ pipenv run pytest -v
36+
$ pytest -v
3337
```
3438

3539
There also are some unit tests, you can run those with cargo:

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ Documentation HTML files can then be found in the `target/doc` directory.
8181
## Contributing
8282

8383
Contributions are more than welcome, and in many cases we are happy to guide
84-
contributors through PRs or on gitter.
84+
contributors through PRs or on gitter. Please refer to the
85+
[development guide](DEVELOPMENT.md) as well for tips on developments.
8586

8687
With that in mind, please note this project is maintained by volunteers, some of
8788
the best ways to get started are below:

src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ use clap::{App, Arg, ArgMatches};
88
use rustpython_compiler::{compile, error::CompileError, error::CompileErrorType};
99
use rustpython_parser::error::ParseErrorType;
1010
use rustpython_vm::{
11-
frame::Scope,
1211
import,
1312
obj::objstr,
1413
print_exception,
1514
pyobject::{ItemProtocol, PyResult},
15+
scope::Scope,
1616
util, PySettings, VirtualMachine,
1717
};
1818
use std::convert::TryInto;

vm/src/builtins.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ use crate::obj::objtype::{self, PyClassRef};
2222
use rustpython_compiler::compile;
2323

2424
use crate::eval::get_compile_mode;
25-
use crate::frame::Scope;
2625
use crate::function::{single_or_tuple_any, Args, KwArgs, OptionalArg, PyFuncArgs};
2726
use crate::pyobject::{
2827
Either, IdProtocol, IntoPyObject, ItemProtocol, PyIterable, PyObjectRef, PyResult, PyValue,
2928
TryFromObject, TypeProtocol,
3029
};
30+
use crate::scope::Scope;
3131
use crate::vm::VirtualMachine;
3232

3333
use crate::obj::objbyteinner::PyByteInner;

vm/src/dictdatatype.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ impl<T: Clone> Dict<T> {
110110
}
111111

112112
/// Retrieve a key
113+
#[cfg_attr(feature = "flame-it", flame("Dict"))]
113114
pub fn get(&self, vm: &VirtualMachine, key: &PyObjectRef) -> PyResult<Option<T>> {
114115
if let LookupResult::Existing(index) = self.lookup(vm, key)? {
115116
Ok(Some(self.unchecked_get(index)))
@@ -197,6 +198,7 @@ impl<T: Clone> Dict<T> {
197198
}
198199

199200
/// Lookup the index for the given key.
201+
#[cfg_attr(feature = "flame-it", flame("Dict"))]
200202
fn lookup(&self, vm: &VirtualMachine, key: &PyObjectRef) -> PyResult<LookupResult> {
201203
let hash_value = collection_hash(vm, key)?;
202204
let perturb = hash_value;
@@ -271,6 +273,7 @@ enum LookupResult {
271273
Existing(EntryIndex), // Existing record, index into entries
272274
}
273275

276+
#[cfg_attr(feature = "flame-it", flame())]
274277
fn collection_hash(vm: &VirtualMachine, object: &PyObjectRef) -> PyResult<HashValue> {
275278
let raw_hash = vm._hash(object)?;
276279
let mut hasher = DefaultHasher::new();

vm/src/eval.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use crate::frame::Scope;
21
use crate::pyobject::PyResult;
2+
use crate::scope::Scope;
33
use crate::vm::VirtualMachine;
44
use rustpython_compiler::compile;
55

0 commit comments

Comments
 (0)