Skip to content

WIP: Function attributes#606

Closed
cthulahoops wants to merge 4 commits into
masterfrom
function_attributes
Closed

WIP: Function attributes#606
cthulahoops wants to merge 4 commits into
masterfrom
function_attributes

Conversation

@cthulahoops
Copy link
Copy Markdown
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
Copy Markdown

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
Copy Markdown
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
Copy Markdown
Contributor

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

@cthulahoops
Copy link
Copy Markdown
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
@youknowone youknowone deleted the function_attributes branch March 7, 2026 00:22
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