Skip to content

Commit 2d78425

Browse files
committed
Add (unused) dict element to PyObject struct.
1 parent 43118db commit 2d78425

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

vm/src/pyobject.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,8 @@ pub struct PyContext {
154154
}
155155

156156
fn _nothing() -> PyObjectRef {
157-
PyObject {
158-
payload: PyObjectPayload::NoPayload,
159-
typ: None,
160-
}
161-
.into_ref()
157+
let obj: PyObject = Default::default();
158+
obj.into_ref()
162159
}
163160

164161
pub fn create_type(
@@ -727,10 +724,11 @@ impl Default for PyContext {
727724
/// This is an actual python object. It consists of a `typ` which is the
728725
/// python class, and carries some rust payload optionally. This rust
729726
/// payload can be a rust float or rust int in case of float and int objects.
727+
#[derive(Default)]
730728
pub struct PyObject {
731729
pub payload: PyObjectPayload,
732730
pub typ: Option<PyObjectRef>,
733-
// pub dict: HashMap<String, PyObjectRef>, // __dict__ member
731+
pub dict: Option<HashMap<String, PyObjectRef>>, // __dict__ member
734732
}
735733

736734
pub trait IdProtocol {
@@ -1507,6 +1505,12 @@ pub enum PyObjectPayload {
15071505
},
15081506
}
15091507

1508+
impl Default for PyObjectPayload {
1509+
fn default() -> Self {
1510+
PyObjectPayload::NoPayload
1511+
}
1512+
}
1513+
15101514
impl fmt::Debug for PyObjectPayload {
15111515
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
15121516
match self {
@@ -1541,14 +1545,11 @@ impl fmt::Debug for PyObjectPayload {
15411545
}
15421546

15431547
impl PyObject {
1544-
pub fn new(
1545-
payload: PyObjectPayload,
1546-
/* dict: PyObjectRef,*/ typ: PyObjectRef,
1547-
) -> PyObjectRef {
1548+
pub fn new(payload: PyObjectPayload, typ: PyObjectRef) -> PyObjectRef {
15481549
PyObject {
15491550
payload,
15501551
typ: Some(typ),
1551-
// dict: HashMap::new(), // dict,
1552+
dict: None,
15521553
}
15531554
.into_ref()
15541555
}

0 commit comments

Comments
 (0)