Skip to content
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

CPython engine marshals python classes to lists when the expectation is to get a handle. #10974

Merged
merged 4 commits into from
Aug 10, 2020

Conversation

mjkkirschner
Copy link
Member

@mjkkirschner mjkkirschner commented Aug 6, 2020

Purpose

While trying to get data-shapes working with the cpython engine it was discovered that some of the data-shapes python classes implement __iter__/__getitem__ and sequence protocols.

These classes are marshaled into dynamo as lists, but for use in data-shapes they need to be marshaled as handles only.

To enable this workflow I've added a new "builtin" 👋 attribute the class author can choose to add to their class. __dynamoskipconversion__. If this attribute exists at all (the return value does not matter) then the object will skip all conversion attempts and immediately be marshaled as a handle.

For dataShapes this means a one line code change to get this class working.

Declarations

Check these if you believe they are true

  • The codebase is in a better state after this PR
  • Is documented according to the standards
  • The level of testing this PR includes is appropriate
  • User facing strings, if any, are extracted into *.resx files
  • All tests pass using the self-service CI.
  • Snapshot of UI changes, if any.
  • Changes to the API follow Semantic Versioning and are documented in the API Changes document.
  • This PR modifies some build requirements and the readme is updated
  • When/If this PR is approved I will update the python3 wiki with information on this attribute.

@mjkkirschner mjkkirschner changed the title Python too much iter CPython engine marshals classes to lists when the expectation is to get a handle. Aug 6, 2020
@mjkkirschner mjkkirschner changed the title CPython engine marshals classes to lists when the expectation is to get a handle. CPython engine marshals python classes to lists when the expectation is to get a handle. Aug 6, 2020
Copy link
Collaborator

@mmisol mmisol left a comment

Choose a reason for hiding this comment

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

Looks good. I left some minor comments

src/Libraries/DSCPython/CPythonEvaluator.cs Show resolved Hide resolved
test/Libraries/DynamoPythonTests/PythonEvalTests.cs Outdated Show resolved Hide resolved
test/Libraries/DynamoPythonTests/PythonEvalTests.cs Outdated Show resolved Hide resolved
@mjkkirschner mjkkirschner merged commit 0348ed0 into DynamoDS:master Aug 10, 2020
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