Fix unnecessary dict comprehension
NONE
_The documentation is not available anymore as the PR was closed or merged._
2023-03-23T09:22:50Z
https://github.com/huggingface/datasets/pull/5662#issuecomment-1480851611
https://api.github.com/repos/huggingface/datasets/issues/5662
IC_kwDODunzps5YRACb
https://api.github.com/repos/huggingface/datasets/issues/comments/1480851611/reactions
2023-03-23T09:40:41Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1480851611
https://avatars.githubusercontent.com/u/99929124?v=4
https://api.github.com/users/HuggingFaceDocBuilderDev/events{/privacy}
https://api.github.com/users/HuggingFaceDocBuilderDev/followers
https://api.github.com/users/HuggingFaceDocBuilderDev/following{/other_user}
https://api.github.com/users/HuggingFaceDocBuilderDev/gists{/gist_id}
https://github.com/HuggingFaceDocBuilderDev
HuggingFaceDocBuilderDev
U_kgDOBfTMJA
https://api.github.com/users/HuggingFaceDocBuilderDev/orgs
https://api.github.com/users/HuggingFaceDocBuilderDev/received_events
https://api.github.com/users/HuggingFaceDocBuilderDev/repos
https://api.github.com/users/HuggingFaceDocBuilderDev/starred{/owner}{/repo}
https://api.github.com/users/HuggingFaceDocBuilderDev/subscriptions
User
https://api.github.com/users/HuggingFaceDocBuilderDev
public
MEMBER
I am merging because the CI error is unrelated.
2023-03-23T09:37:03Z
https://github.com/huggingface/datasets/pull/5662#issuecomment-1480872025
https://api.github.com/repos/huggingface/datasets/issues/5662
IC_kwDODunzps5YRFBZ
https://api.github.com/repos/huggingface/datasets/issues/comments/1480872025/reactions
2023-03-23T09:37:03Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1480872025
https://avatars.githubusercontent.com/u/8515462?v=4
https://api.github.com/users/albertvillanova/events{/privacy}
https://api.github.com/users/albertvillanova/followers
https://api.github.com/users/albertvillanova/following{/other_user}
https://api.github.com/users/albertvillanova/gists{/gist_id}
https://github.com/albertvillanova
albertvillanova
MDQ6VXNlcjg1MTU0NjI=
https://api.github.com/users/albertvillanova/orgs
https://api.github.com/users/albertvillanova/received_events
https://api.github.com/users/albertvillanova/repos
https://api.github.com/users/albertvillanova/starred{/owner}{/repo}
https://api.github.com/users/albertvillanova/subscriptions
User
https://api.github.com/users/albertvillanova
public
NONE
<details>
<summary>Show benchmarks</summary>

PyArrow==8.0.0

<details>
<summary>Show updated benchmarks!</summary>

### Benchmark: benchmark_array_xd.json

| metric | read_batch_formatted_as_numpy after write_array2d | read_batch_formatted_as_numpy after write_flattened_sequence | read_batch_formatted_as_numpy after write_nested_sequence | read_batch_unformated after write_array2d | read_batch_unformated after write_flattened_sequence | read_batch_unformated after write_nested_sequence | read_col_formatted_as_numpy after write_array2d | read_col_formatted_as_numpy after write_flattened_sequence | read_col_formatted_as_numpy after write_nested_sequence | read_col_unformated after write_array2d | read_col_unformated after write_flattened_sequence | read_col_unformated after write_nested_sequence | read_formatted_as_numpy after write_array2d | read_formatted_as_numpy after write_flattened_sequence | read_formatted_as_numpy after write_nested_sequence | read_unformated after write_array2d | read_unformated after write_flattened_sequence | read_unformated after write_nested_sequence | write_array2d | write_flattened_sequence | write_nested_sequence |
|--------|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| new / old (diff) | 0.009448 / 0.011353 (-0.001905) | 0.006156 / 0.011008 (-0.004852) | 0.123656 / 0.038508 (0.085147) | 0.034998 / 0.023109 (0.011889) | 0.374722 / 0.275898 (0.098824) | 0.418912 / 0.323480 (0.095432) | 0.007348 / 0.007986 (-0.000637) | 0.004779 / 0.004328 (0.000450) | 0.097541 / 0.004250 (0.093291) | 0.052523 / 0.037052 (0.015471) | 0.380118 / 0.258489 (0.121628) | 0.429448 / 0.293841 (0.135607) | 0.055156 / 0.128546 (-0.073390) | 0.019884 / 0.075646 (-0.055763) | 0.429613 / 0.419271 (0.010341) | 0.067554 / 0.043533 (0.024021) | 0.373940 / 0.255139 (0.118801) | 0.408115 / 0.283200 (0.124916) | 0.111353 / 0.141683 (-0.030329) | 1.821013 / 1.452155 (0.368858) | 1.972882 / 1.492716 (0.480165) |

### Benchmark: benchmark_getitem\_100B.json

| metric | get_batch_of\_1024\_random_rows | get_batch_of\_1024\_rows | get_first_row | get_last_row |
|--------|---|---|---|---|
| new / old (diff) | 0.236686 / 0.018006 (0.218679) | 0.516519 / 0.000490 (0.516029) | 0.009582 / 0.000200 (0.009383) | 0.000404 / 0.000054 (0.000349) |

### Benchmark: benchmark_indices_mapping.json

| metric | select | shard | shuffle | sort | train_test_split |
|--------|---|---|---|---|---|
| new / old (diff) | 0.029425 / 0.037411 (-0.007986) | 0.123972 / 0.014526 (0.109446) | 0.133768 / 0.176557 (-0.042789) | 0.207562 / 0.737135 (-0.529573) | 0.142841 / 0.296338 (-0.153497) |

### Benchmark: benchmark_iterating.json

| metric | read 5000 | read 50000 | read_batch 50000 10 | read_batch 50000 100 | read_batch 50000 1000 | read_formatted numpy 5000 | read_formatted pandas 5000 | read_formatted tensorflow 5000 | read_formatted torch 5000 | read_formatted_batch numpy 5000 10 | read_formatted_batch numpy 5000 1000 | shuffled read 5000 | shuffled read 50000 | shuffled read_batch 50000 10 | shuffled read_batch 50000 100 | shuffled read_batch 50000 1000 | shuffled read_formatted numpy 5000 | shuffled read_formatted_batch numpy 5000 10 | shuffled read_formatted_batch numpy 5000 1000 |
|--------|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| new / old (diff) | 0.618531 / 0.215209 (0.403322) | 6.216854 / 2.077655 (4.139199) | 2.480138 / 1.504120 (0.976018) | 2.139884 / 1.541195 (0.598689) | 2.122992 / 1.468490 (0.654502) | 1.233824 / 4.584777 (-3.350953) | 5.426142 / 3.745712 (1.680430) | 4.891039 / 5.269862 (-0.378822) | 2.767033 / 4.565676 (-1.798643) | 0.142224 / 0.424275 (-0.282051) | 0.015754 / 0.007607 (0.008147) | 0.772210 / 0.226044 (0.546166) | 7.620484 / 2.268929 (5.351556) | 3.141617 / 55.444624 (-52.303007) | 2.471406 / 6.876477 (-4.405070) | 2.648008 / 2.142072 (0.505935) | 1.429281 / 4.805227 (-3.375946) | 0.255981 / 6.500664 (-6.244683) | 0.077710 / 0.075469 (0.002241) |

### Benchmark: benchmark_map_filter.json

| metric | filter | map fast-tokenizer batched | map identity | map identity batched | map no-op batched | map no-op batched numpy | map no-op batched pandas | map no-op batched pytorch | map no-op batched tensorflow |
|--------|---|---|---|---|---|---|---|---|---|
| new / old (diff) | 1.547714 / 1.841788 (-0.294073) | 17.859985 / 8.074308 (9.785677) | 21.791878 / 10.191392 (11.600486) | 0.238569 / 0.680424 (-0.441854) | 0.027520 / 0.534201 (-0.506681) | 0.553960 / 0.579283 (-0.025324) | 0.616165 / 0.434364 (0.181801) | 0.622492 / 0.540337 (0.082154) | 0.716345 / 1.386936 (-0.670591) |

</details>
PyArrow==latest

<details>
<summary>Show updated benchmarks!</summary>

### Benchmark: benchmark_array_xd.json

| metric | read_batch_formatted_as_numpy after write_array2d | read_batch_formatted_as_numpy after write_flattened_sequence | read_batch_formatted_as_numpy after write_nested_sequence | read_batch_unformated after write_array2d | read_batch_unformated after write_flattened_sequence | read_batch_unformated after write_nested_sequence | read_col_formatted_as_numpy after write_array2d | read_col_formatted_as_numpy after write_flattened_sequence | read_col_formatted_as_numpy after write_nested_sequence | read_col_unformated after write_array2d | read_col_unformated after write_flattened_sequence | read_col_unformated after write_nested_sequence | read_formatted_as_numpy after write_array2d | read_formatted_as_numpy after write_flattened_sequence | read_formatted_as_numpy after write_nested_sequence | read_unformated after write_array2d | read_unformated after write_flattened_sequence | read_unformated after write_nested_sequence | write_array2d | write_flattened_sequence | write_nested_sequence |
|--------|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| new / old (diff) | 0.009624 / 0.011353 (-0.001729) | 0.006091 / 0.011008 (-0.004917) | 0.096623 / 0.038508 (0.058115) | 0.034903 / 0.023109 (0.011793) | 0.421009 / 0.275898 (0.145111) | 0.459236 / 0.323480 (0.135756) | 0.007778 / 0.007986 (-0.000207) | 0.004726 / 0.004328 (0.000398) | 0.099603 / 0.004250 (0.095353) | 0.051426 / 0.037052 (0.014373) | 0.420461 / 0.258489 (0.161972) | 0.469747 / 0.293841 (0.175906) | 0.053769 / 0.128546 (-0.074777) | 0.020636 / 0.075646 (-0.055011) | 0.115785 / 0.419271 (-0.303486) | 0.062692 / 0.043533 (0.019160) | 0.419388 / 0.255139 (0.164249) | 0.448675 / 0.283200 (0.165475) | 0.112099 / 0.141683 (-0.029584) | 1.787982 / 1.452155 (0.335827) | 1.884581 / 1.492716 (0.391864) |

### Benchmark: benchmark_getitem\_100B.json

| metric | get_batch_of\_1024\_random_rows | get_batch_of\_1024\_rows | get_first_row | get_last_row |
|--------|---|---|---|---|
| new / old (diff) | 0.208837 / 0.018006 (0.190831) | 0.515593 / 0.000490 (0.515103) | 0.000447 / 0.000200 (0.000247) | 0.000086 / 0.000054 (0.000032) |

### Benchmark: benchmark_indices_mapping.json

| metric | select | shard | shuffle | sort | train_test_split |
|--------|---|---|---|---|---|
| new / old (diff) | 0.031025 / 0.037411 (-0.006386) | 0.125179 / 0.014526 (0.110653) | 0.137050 / 0.176557 (-0.039506) | 0.203582 / 0.737135 (-0.533553) | 0.139209 / 0.296338 (-0.157130) |

### Benchmark: benchmark_iterating.json

| metric | read 5000 | read 50000 | read_batch 50000 10 | read_batch 50000 100 | read_batch 50000 1000 | read_formatted numpy 5000 | read_formatted pandas 5000 | read_formatted tensorflow 5000 | read_formatted torch 5000 | read_formatted_batch numpy 5000 10 | read_formatted_batch numpy 5000 1000 | shuffled read 5000 | shuffled read 50000 | shuffled read_batch 50000 10 | shuffled read_batch 50000 100 | shuffled read_batch 50000 1000 | shuffled read_formatted numpy 5000 | shuffled read_formatted_batch numpy 5000 10 | shuffled read_formatted_batch numpy 5000 1000 |
|--------|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| new / old (diff) | 0.601507 / 0.215209 (0.386298) | 6.034778 / 2.077655 (3.957123) | 2.550277 / 1.504120 (1.046157) | 2.242277 / 1.541195 (0.701082) | 2.306378 / 1.468490 (0.837888) | 1.251219 / 4.584777 (-3.333558) | 5.448698 / 3.745712 (1.702986) | 3.044666 / 5.269862 (-2.225196) | 2.000684 / 4.565676 (-2.564992) | 0.148385 / 0.424275 (-0.275890) | 0.015175 / 0.007607 (0.007567) | 0.800839 / 0.226044 (0.574795) | 8.062099 / 2.268929 (5.793171) | 3.400980 / 55.444624 (-52.043644) | 2.639583 / 6.876477 (-4.236894) | 2.660691 / 2.142072 (0.518618) | 1.467715 / 4.805227 (-3.337512) | 0.266429 / 6.500664 (-6.234235) | 0.076981 / 0.075469 (0.001512) |

### Benchmark: benchmark_map_filter.json

| metric | filter | map fast-tokenizer batched | map identity | map identity batched | map no-op batched | map no-op batched numpy | map no-op batched pandas | map no-op batched pytorch | map no-op batched tensorflow |
|--------|---|---|---|---|---|---|---|---|---|
| new / old (diff) | 1.621128 / 1.841788 (-0.220659) | 17.949989 / 8.074308 (9.875680) | 20.946426 / 10.191392 (10.755034) | 0.259357 / 0.680424 (-0.421067) | 0.026094 / 0.534201 (-0.508107) | 0.527840 / 0.579283 (-0.051443) | 0.629027 / 0.434364 (0.194663) | 0.603931 / 0.540337 (0.063594) | 0.711370 / 1.386936 (-0.675566) |

</details>
</details>

![](https://cml.dev/watermark.png#2ccf01db81bb7b70f3ea97b185e345c2b1df0274 "CML watermark")

2023-03-23T09:46:58Z
https://github.com/huggingface/datasets/pull/5662#issuecomment-1480885282
https://api.github.com/repos/huggingface/datasets/issues/5662
IC_kwDODunzps5YRIQi
https://api.github.com/repos/huggingface/datasets/issues/comments/1480885282/reactions
2023-03-23T09:46:58Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1480885282
https://avatars.githubusercontent.com/in/15368?v=4
https://api.github.com/users/github-actions%5Bbot%5D/events{/privacy}
https://api.github.com/users/github-actions%5Bbot%5D/followers
https://api.github.com/users/github-actions%5Bbot%5D/following{/other_user}
https://api.github.com/users/github-actions%5Bbot%5D/gists{/gist_id}
https://github.com/apps/github-actions
github-actions[bot]
MDM6Qm90NDE4OTgyODI=
https://api.github.com/users/github-actions%5Bbot%5D/orgs
https://api.github.com/users/github-actions%5Bbot%5D/received_events
https://api.github.com/users/github-actions%5Bbot%5D/repos
https://api.github.com/users/github-actions%5Bbot%5D/starred{/owner}{/repo}
https://api.github.com/users/github-actions%5Bbot%5D/subscriptions
Bot
https://api.github.com/users/github-actions%5Bbot%5D
public
After ruff-0.0.258 release, the C416 rule was updated with unnecessary dict comprehensions. See:
- https://github.com/charliermarsh/ruff/releases/tag/v0.0.258
- https://github.com/charliermarsh/ruff/pull/3605

This PR fixes one unnecessary dict comprehension in our code: no need to unpack and re-pack the tuple values.

Fix #5661