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


##########
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 think I found a good balance between the extra set creation and using the 
existing list. I ended up reusing an existing dictionary keyed by join keys for 
the lookup. That is a tiny bit slower than using a set for the lookup but it's 
faster than list and doesn't involve any extra code.
   
   Also if you account for the extra set creation it's actually faster
   ```
   >>> timeit.timeit("right_keys_long_s = set(right_keys_long); [col for col in 
right_columns_long if col not in right_keys_long_s]", globals=globals())
   0.30407846500747837
   >>> timeit.timeit("[col for col in right_columns_long if col not in 
right_keys_long_d]", globals=globals())
   0.24310287900152616
   ```



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