FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Add some extra profiling trace points. by windelbouwman · Pull Request #1169 · RustPython/RustPython · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .md  (2) .rs  (15) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
8 changes: 6 additions & 2 deletions DEVELOPMENT.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@

## Code organization

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

```shell
$ cd tests
$ pipenv install
$ pipenv run pytest -v
$ pytest -v
```

There also are some unit tests, you can run those with cargo:
Expand Down
3 changes: 2 additions & 1 deletion README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ Documentation HTML files can then be found in the `target/doc` directory.
## Contributing

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

With that in mind, please note this project is maintained by volunteers, some of
the best ways to get started are below:
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ use clap::{App, Arg, ArgMatches};
use rustpython_compiler::{compile, error::CompileError, error::CompileErrorType};
use rustpython_parser::error::ParseErrorType;
use rustpython_vm::{
frame::Scope,
import,
obj::objstr,
print_exception,
pyobject::{ItemProtocol, PyResult},
scope::Scope,
util, PySettings, VirtualMachine,
};
use std::convert::TryInto;
Expand Down
2 changes: 1 addition & 1 deletion vm/src/builtins.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ use crate::obj::objtype::{self, PyClassRef};
use rustpython_compiler::compile;

use crate::eval::get_compile_mode;
use crate::frame::Scope;
use crate::function::{single_or_tuple_any, Args, KwArgs, OptionalArg, PyFuncArgs};
use crate::pyobject::{
Either, IdProtocol, IntoPyObject, ItemProtocol, PyIterable, PyObjectRef, PyResult, PyValue,
TryFromObject, TypeProtocol,
};
use crate::scope::Scope;
use crate::vm::VirtualMachine;

use crate::obj::objbyteinner::PyByteInner;
Expand Down
3 changes: 3 additions & 0 deletions vm/src/dictdatatype.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ impl<T: Clone> Dict<T> {
}

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

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

The string passed to flame is a prefix, so this would appear in the output as collection_hash::collection_hash. I'd recommend changing it to dictdatatype or removing the prefix altogether.


#[cfg_attr(feature = "flame-it", flame())]
fn collection_hash(vm: &VirtualMachine, object: &PyObjectRef) -> PyResult<HashValue> {
let raw_hash = vm._hash(object)?;
let mut hasher = DefaultHasher::new();
Expand Down
2 changes: 1 addition & 1 deletion vm/src/eval.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::frame::Scope;
use crate::pyobject::PyResult;
use crate::scope::Scope;
use crate::vm::VirtualMachine;
use rustpython_compiler::compile;

Expand Down
Loading

Back | FazBrowse Home | New Git URL