Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions vm/src/stdlib/itertools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ mod decl {
AsObject, Py, PyObjectRef, PyPayload, PyRef, PyResult, PyWeakRef, VirtualMachine,
};
use crossbeam_utils::atomic::AtomicCell;
use num_traits::{Signed, ToPrimitive};
use num_traits::{Signed, ToPrimitive, One};
use std::fmt;

#[pyattr]
Expand Down Expand Up @@ -220,10 +220,13 @@ mod decl {
}

#[pymethod(magic)]
fn repr(&self) -> PyResult<String> {
let cur = self.cur.read();

Ok(format!("count({})", cur))
fn repr(&self, vm: &VirtualMachine) -> PyResult<String> {
let cur = format!("{}", self.cur.read().clone().repr(vm)?);
let step = self.step.as_bigint();
if step.is_one() {
return Ok(format!("count({})", cur));
}
Ok(format!("count({}, {})", cur, step.to_string()))
}
}
impl IterNextIterable for PyItertoolsCount {}
Expand Down