[ https://issues.apache.org/jira/browse/BEAM-7746?focusedWorklogId=282390&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-282390 ]
ASF GitHub Bot logged work on BEAM-7746: ---------------------------------------- Author: ASF GitHub Bot Created on: 25/Jul/19 02:15 Start Date: 25/Jul/19 02:15 Worklog Time Spent: 10m Work Description: chadrik commented on issue #9056: [BEAM-7746] Add python type hints URL: https://github.com/apache/beam/pull/9056#issuecomment-514867260 > Passing self.thing as a default argument causes it to get pickled with the lambda and makes it a distinct object after unpickling. yes, any object will be a distinct object after unpickling: ``` >>> import dill >>> o = object() >>> o_loaded = dill.loads(dill.dumps(o)) >>> o == o_loaded False >>> id(o) 4402307584 >>> id(o_loaded) 4405359896 ``` But this is just an implementation detail of `object`. `object.__eq__` is likely doing an `id()` check, and this test simply demonstrates that you should not use `object` with pickle/dill if equality checks are important to your code. Luckily, it is possible for distinctly different objects to behave the same (otherwise beam wouldn't work at all): ``` >>> import dill >>> o = [1, 2] >>> o_loaded = dill.loads(dill.dumps(o)) >>> o == o_loaded True 4402307585 >>> id(o_loaded) 4405359892 ``` Anyway, IIUC, the function and the args passed to `DoFn` will _both_ be serialized using dill, so the argument object in question should undergo a serialization/deserialization transformation either way. My question was more about the details of the beam internals, esp as it might pertain to portability, grpc model, and urns etc that I would not be familiar with as a beam newbie. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking ------------------- Worklog Id: (was: 282390) Time Spent: 5h 50m (was: 5h 40m) > Add type hints to python code > ----------------------------- > > Key: BEAM-7746 > URL: https://issues.apache.org/jira/browse/BEAM-7746 > Project: Beam > Issue Type: New Feature > Components: sdk-py-core > Reporter: Chad Dombrova > Assignee: Chad Dombrova > Priority: Major > Time Spent: 5h 50m > Remaining Estimate: 0h > > As a developer of the beam source code, I would like the code to use pep484 > type hints so that I can clearly see what types are required, get completion > in my IDE, and enforce code correctness via a static analyzer like mypy. > This may be considered a precursor to BEAM-7060 > Work has been started here: [https://github.com/apache/beam/pull/9056] > > -- This message was sent by Atlassian JIRA (v7.6.14#76016)