You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by "AnandInguva (via GitHub)" <gi...@apache.org> on 2023/03/13 14:27:43 UTC

[GitHub] [beam] AnandInguva commented on a diff in pull request #25795: Add support for CPython 3.11 opcodes

AnandInguva commented on code in PR #25795:
URL: https://github.com/apache/beam/pull/25795#discussion_r1134013626


##########
sdks/python/apache_beam/typehints/trivial_inference.py:
##########
@@ -374,7 +378,12 @@ def infer_return_type_func(f, input_types, debug=False, depth=0):
   # In Python 3, use dis library functions to disassemble bytecode and handle
   # EXTENDED_ARGs.
   ofs_table = {}  # offset -> instruction
-  for instruction in dis.get_instructions(f):
+  if (sys.version_info.major, sys.version_info.minor) >= (3, 11):
+    disInts = dis.get_instructions(f, show_caches=True)

Review Comment:
   ```suggestion
       dis_ints = dis.get_instructions(f, show_caches=True)
   ```
   
   Can we follow PEP-8 for variable naming? [Function and Variable Names](https://peps.python.org/pep-0008/#function-and-variable-names)



##########
sdks/python/apache_beam/typehints/trivial_inference.py:
##########
@@ -408,17 +418,27 @@ def infer_return_type_func(f, input_types, debug=False, depth=0):
         if op in dis.hasconst:
           print('(' + repr(co.co_consts[arg]) + ')', end=' ')
         elif op in dis.hasname:
-          print('(' + co.co_names[arg] + ')', end=' ')
+          if (sys.version_info.major, sys.version_info.minor) >= (3, 11):
+            # Pre-emptively bit-shift so the print doesn't go out of index
+            printArg = arg >> 1

Review Comment:
   I didn't understand. Why do we do this for 3.11? 



##########
sdks/python/apache_beam/typehints/trivial_inference_test.py:
##########
@@ -299,7 +299,7 @@ def m(self, x):
         return x
 
     self.assertReturnType(int, lambda: A().m(3))
-    self.assertReturnType(float, lambda: A.m(A(), 3.0))
+    #self.assertReturnType(float, lambda: A.m(A(), 3.0))

Review Comment:
   why did we comment this test?



-- 
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.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org