[
https://issues.apache.org/jira/browse/BEAM-3981?focusedWorklogId=86814&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-86814
]
ASF GitHub Bot logged work on BEAM-3981:
----------------------------------------
Author: ASF GitHub Bot
Created on: 02/Apr/18 22:25
Start Date: 02/Apr/18 22:25
Worklog Time Spent: 10m
Work Description: RobbeSneyders commented on issue #4990: [BEAM-3981]
[WIP] Futurize and fix python 2 compatibility for coders subpackage
URL: https://github.com/apache/beam/pull/4990#issuecomment-378065718
Thanks for the review @charlesccychen.
Some general points based on your feedback and my answers:
- The imports:
`from __future__ import absolute_import`
`from __future__ import division`
`from __future__ import print_function`
were added at the top of each updated module to prevent regression before
full python 3 support is added. This way no new code can be added using for
instance the old python 2 division. Another benefit is the consistency of
division and print across modules.
- `from builtins import ...` imports from future.builtins on python 2 and
has no effect on python 3. future.builtins contains a bunch of backported
python 3 builtins for compatibility.
I actually think it's best to add `from builtins import *` to every module.
Just like the \_\_future\_\_ imports, this helps avoid regression and adds
consistency. This however still breaks some tests. I'll try to fix these and
update the pull request later.
- The bytes type annotation was removed in the stream cython files because
it was breaking due to a mismatch between the cython bytes type and the future
bytes type. However, this is not meant to be merged this way, but I wanted to
submit the pull request with working code to get some feedback on this. I have
tried replacing bytes with a memory view as explained
[here](http://cython.readthedocs.io/en/latest/src/tutorial/strings.html#accepting-strings-from-python-code),
but this resulted in a packaging error. Any help on this is appreciated.
- The Cython version was upgraded from 0.26.1 to 0.28.1 because of an
incompatibility between cython and future types. I have not noticed any
backward incompatibility.
- The is type checks were replaced by isinstance checks because the
future.builtins are all subclasses of the standard python classes. However,
works a lot slower. I could revert this change if I use six again for
compatibility. The drawback is that `str` and `bytes` will work different
across modules.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 86814)
Time Spent: 4h 50m (was: 4h 40m)
> Futurize and fix python 2 compatibility for coders package
> ----------------------------------------------------------
>
> Key: BEAM-3981
> URL: https://issues.apache.org/jira/browse/BEAM-3981
> Project: Beam
> Issue Type: Sub-task
> Components: sdk-py-core
> Reporter: Robbe
> Assignee: Ahmet Altay
> Priority: Major
> Time Spent: 4h 50m
> Remaining Estimate: 0h
>
> Run automatic conversion with futurize tool on coders subpackage and fix
> python 2 compatibility. This prepares the subpackage for python 3 support.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)