amol- commented on code in PR #13281:
URL: https://github.com/apache/arrow/pull/13281#discussion_r886950636


##########
python/pyarrow/_exec_plan.pyx:
##########
@@ -259,13 +259,19 @@ def _perform_join(join_type, left_operand not None, 
left_keys,
         left_columns = []
     elif join_type == "inner":
         c_join_type = CJoinType_INNER
-        right_columns = set(right_columns) - set(right_keys)
+        right_columns = [
+            col for col in right_columns if col not in set(right_keys)

Review Comment:
   I was going to post some benchmarks in my previous answer, but I realised 
that in the end they didn't change much given that the keys will be in the 
order of single digit and the list was less code. So I went for the list. 
   
   I don't have a strong opinion over this one, in all cases it looks like a 
minor change.
   
   ```
   >>> import timeit
   >>> right_columns =  ["a", "b", "c", "d", "e", "f"]
   >>> right_keys = ["b", "c"]
   >>> right_keys_s = set(right_keys)
   >>> timeit.timeit(lambda: [col for col in right_columns if col not in 
set(right_keys)])
   0.541847073007375
   >>> timeit.timeit(lambda: [col for col in right_columns if col not in 
right_keys])
   0.3103783940023277
   >>> timeit.timeit(lambda: [col for col in right_columns if col not in 
right_keys_s])
   0.236496517987689
   
   >>> right_columns_long = ["panelist_question_answer_1", 
"panelist_question_answer_2", "panelist_question_answer_3", 
"panelist_question_answer_4", "panelist_question_answer_5", 
"panelist_question_answer_6"]
   >>> right_keys_long = [ "panelist_question_answer_2", 
"panelist_question_answer_3" ]
   >>> right_keys_long_s = set(right_keys_long)
   >>> timeit.timeit(lambda: [col for col in right_columns_long if col not in 
set(right_keys_long)])
   0.5470193719957024
   >>> timeit.timeit(lambda: [col for col in right_columns_long if col not in 
right_keys_long])
   0.32604770400212146
   >>> timeit.timeit(lambda: [col for col in right_columns_long if col not in 
right_keys_long_s])
   0.2378907290112693
   ```



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to