Skip to content

Object protocol#3306

Merged
youknowone merged 1 commit into
RustPython:mainfrom
youknowone:object-protocol
Oct 16, 2021
Merged

Object protocol#3306
youknowone merged 1 commit into
RustPython:mainfrom
youknowone:object-protocol

Conversation

@youknowone

@youknowone youknowone commented Oct 14, 2021

Copy link
Copy Markdown
Member

I also suggest to replace the paired vm methods and use PyObjectRef methods

ref #3244

Comment thread vm/src/types/slot.rs
Comment on lines +489 to +490
fn __hash__(zelf: PyObjectRef, vm: &VirtualMachine) -> PyResult<PyHash> {
Self::slot_hash(&zelf, vm)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this intended to include in this PR, not in #3308 ?

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.

He'll probably just rebase those changes here now that they've been merged.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The below Unhashable changes require this. Will moving them into #3308 be better?

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.

I think it makes more sense to move it over to #3308

@Snowapril Snowapril Oct 16, 2021

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think it makes more sense to move it over to #3308

Sorry for late 😢. I also agree with him

@DimitrisJim

Copy link
Copy Markdown
Member

I also suggest to replace the paired vm methods and use PyObjectRef methods

yup, I think that's a good idea. After this pr there will be two ways to do the same thing. As I see it, these operations act on objects so they should be exposed through there and not through vm.

@DimitrisJim

DimitrisJim commented Oct 16, 2021

Copy link
Copy Markdown
Member

should ItemProtocol impl be moved here too?

@youknowone

Copy link
Copy Markdown
Member Author

Probably. I doub't we really need that trait now. I think relocating impl ItemProtocol for PyObjectRef to here, impl ItemProtocol for PyDictRef to its impl and removing the trait could be better than now.

@DimitrisJim

Copy link
Copy Markdown
Member

The delitem/setitem/getitem in PyDict would need to also be made public so objects that are known to be dicts to be able to call directly into them.

@youknowone

Copy link
Copy Markdown
Member Author

@DimitrisJim could you review it? I want to open issue for relocating functino bodies and refactoring around them.

@DimitrisJim DimitrisJim left a comment

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.

I thought I had reviewed but this does lgtm.

@youknowone youknowone merged commit 273193f into RustPython:main Oct 16, 2021
@youknowone youknowone deleted the object-protocol branch October 16, 2021 18:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants