| 589 | impl Representable for PyDict { |
| 590 | #[inline] |
| 591 | fn repr(zelf: &Py<Self>, vm: &VirtualMachine) -> PyResult<PyStrRef> { |
| 592 | let s = if let Some(_guard) = ReprGuard::enter(vm, zelf.as_object()) { |
| 593 | let mut result = Wtf8Buf::from("{"); |
| 594 | let mut first = true; |
| 595 | for (key, value) in zelf { |
| 596 | if !first { |
| 597 | result.push_str(", "); |
| 598 | } |
| 599 | first = false; |
| 600 | result.push_wtf8(key.repr(vm)?.as_wtf8()); |
| 601 | result.push_str(": "); |
| 602 | result.push_wtf8(value.repr(vm)?.as_wtf8()); |
| 603 | } |
| 604 | result.push_char('}'); |
| 605 | vm.ctx.new_str(result) |
| 606 | } else { |
| 607 | vm.ctx.intern_str("{...}").to_owned() |
| 608 | }; |
| 609 | Ok(s) |
| 610 | } |
| 611 | |
| 612 | #[cold] |
| 613 | fn repr_str(_zelf: &Py<Self>, _vm: &VirtualMachine) -> PyResult<String> { |