Skip to content

WIP: Function attributes #606

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed

WIP: Function attributes #606

wants to merge 4 commits into from

Conversation

cthulahoops
Copy link
Collaborator

Experiment with having an attributes dictionary on PyObject (so that we can give attributes to more objects).

I've included my other branch to avoid having to disentangle these changes. (I rely on NoPayload here for instances.) Pushing this so we can see how it looks.

@codecov-io
Copy link

Codecov Report

Merging #606 into master will decrease coverage by 0.1%.
The diff coverage is 38.61%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #606      +/-   ##
==========================================
- Coverage    41.2%   41.09%   -0.11%     
==========================================
  Files          75       75              
  Lines       17094    17125      +31     
  Branches     4543     4527      -16     
==========================================
- Hits         7043     7038       -5     
- Misses       8014     8048      +34     
- Partials     2037     2039       +2
Impacted Files Coverage Δ
vm/src/stdlib/json.rs 39.02% <0%> (ø) ⬆️
vm/src/obj/objdict.rs 41.25% <100%> (ø) ⬆️
vm/src/obj/objbool.rs 38.46% <100%> (-4.75%) ⬇️
vm/src/obj/objobject.rs 38.34% <18.18%> (-0.08%) ⬇️
vm/src/frame.rs 47.36% <23.52%> (+0.19%) ⬆️
vm/src/obj/objtype.rs 42.33% <28.57%> (-0.57%) ⬇️
vm/src/vm.rs 53.94% <33.33%> (-0.34%) ⬇️
vm/src/pyobject.rs 58.08% <46.66%> (-2.34%) ⬇️
vm/src/obj/objnone.rs 78.94% <80%> (+26.31%) ⬆️
... and 5 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d278fb8...1d1a931. Read the comment docs.

@adrian17
Copy link
Contributor

adrian17 commented Mar 6, 2019

With this patch applied:

>>>>> a = 1
>>>>> a.asdf = 4
thread 'main' panicked at 'not yet implemented: set_attr unimplemented for: [PyObj int 1]', vm/src/pyobject.rs:690:13

CPython:

>>> a = 5
>>> a.asdf = 4
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'int' object has no attribute 'asdf'
>>> setattr(a, 'asdf', 4)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'int' object has no attribute 'asdf'

@windelbouwman
Copy link
Contributor

This looks good to me! Please resolve the conflict, so we can merge it.

@cthulahoops
Copy link
Collaborator Author

I'm leaning towards the parent payload approach as suggested in chat. I'm planning on opening a separate PR for that so we can compare / contrast.

It keeps the struct smaller for the vast majority of items that don't have a attributes and payload, and I think it's simple to get the parent payload to extract transparently.

@cthulahoops cthulahoops mentioned this pull request Mar 6, 2019
@cthulahoops cthulahoops closed this Mar 7, 2019
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.

4 participants