Fix benchmarks CI - pin protobuf

_The documentation is not available anymore as the PR was closed or merged._

Show benchmarks

PyArrow==6.0.0

Show updated benchmarks!

### 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.011142 / 0.011353 (-0.000211) | 0.005885 / 0.011008 (-0.005123) | 0.115374 / 0.038508 (0.076866) | 0.041704 / 0.023109 (0.018594) | 0.356996 / 0.275898 (0.081098) | 0.395076 / 0.323480 (0.071596) | 0.008726 / 0.007986 (0.000740) | 0.005528 / 0.004328 (0.001199) | 0.087817 / 0.004250 (0.083566) | 0.049273 / 0.037052 (0.012221) | 0.363778 / 0.258489 (0.105289) | 0.408801 / 0.293841 (0.114960) | 0.045232 / 0.128546 (-0.083314) | 0.013788 / 0.075646 (-0.061859) | 0.395634 / 0.419271 (-0.023637) | 0.056583 / 0.043533 (0.013051) | 0.360779 / 0.255139 (0.105640) | 0.386843 / 0.283200 (0.103643) | 0.116632 / 0.141683 (-0.025051) | 1.830020 / 1.452155 (0.377865) | 1.808720 / 1.492716 (0.316003) |

### 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.221029 / 0.018006 (0.203023) | 0.489463 / 0.000490 (0.488973) | 0.002104 / 0.000200 (0.001904) | 0.000098 / 0.000054 (0.000043) |

### Benchmark: benchmark_indices_mapping.json

| metric | select | shard | shuffle | sort | train_test_split |
|--------|---|---|---|---|---|
| new / old (diff) | 0.032873 / 0.037411 (-0.004539) | 0.129526 / 0.014526 (0.115000) | 0.141446 / 0.176557 (-0.035111) | 0.189222 / 0.737135 (-0.547913) | 0.149329 / 0.296338 (-0.147010) |

### 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.471389 / 0.215209 (0.256180) | 4.710174 / 2.077655 (2.632519) | 2.239122 / 1.504120 (0.735002) | 1.977789 / 1.541195 (0.436595) | 2.107336 / 1.468490 (0.638846) | 0.816852 / 4.584777 (-3.767925) | 4.944056 / 3.745712 (1.198344) | 4.637939 / 5.269862 (-0.631922) | 2.355546 / 4.565676 (-2.210131) | 0.099324 / 0.424275 (-0.324951) | 0.014529 / 0.007607 (0.006922) | 0.596322 / 0.226044 (0.370277) | 5.972216 / 2.268929 (3.703287) | 2.697281 / 55.444624 (-52.747344) | 2.293836 / 6.876477 (-4.582641) | 2.380271 / 2.142072 (0.238199) | 1.001307 / 4.805227 (-3.803920) | 0.196981 / 6.500664 (-6.303683) | 0.074390 / 0.075469 (-0.001079) |

### 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.482915 / 1.841788 (-0.358872) | 18.739511 / 8.074308 (10.665202) | 16.768191 / 10.191392 (6.576799) | 0.203163 / 0.680424 (-0.477261) | 0.037514 / 0.534201 (-0.496687) | 0.529017 / 0.579283 (-0.050266) | 0.577591 / 0.434364 (0.143227) | 0.634057 / 0.540337 (0.093720) | 0.759812 / 1.386936 (-0.627124) |

PyArrow==latest

Show updated benchmarks!

### 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.008815 / 0.011353 (-0.002537) | 0.005956 / 0.011008 (-0.005052) | 0.087912 / 0.038508 (0.049404) | 0.040291 / 0.023109 (0.017182) | 0.404079 / 0.275898 (0.128181) | 0.447309 / 0.323480 (0.123829) | 0.006515 / 0.007986 (-0.001471) | 0.005917 / 0.004328 (0.001588) | 0.085560 / 0.004250 (0.081310) | 0.057077 / 0.037052 (0.020025) | 0.403349 / 0.258489 (0.144860) | 0.465644 / 0.293841 (0.171803) | 0.043530 / 0.128546 (-0.085016) | 0.014234 / 0.075646 (-0.061412) | 0.102203 / 0.419271 (-0.317068) | 0.058335 / 0.043533 (0.014802) | 0.398488 / 0.255139 (0.143349) | 0.424127 / 0.283200 (0.140927) | 0.119058 / 0.141683 (-0.022625) | 1.748748 / 1.452155 (0.296593) | 1.822190 / 1.492716 (0.329474) |

### 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.255782 / 0.018006 (0.237776) | 0.496665 / 0.000490 (0.496176) | 0.000471 / 0.000200 (0.000271) | 0.000069 / 0.000054 (0.000014) |

### Benchmark: benchmark_indices_mapping.json

| metric | select | shard | shuffle | sort | train_test_split |
|--------|---|---|---|---|---|
| new / old (diff) | 0.034111 / 0.037411 (-0.003301) | 0.131442 / 0.014526 (0.116917) | 0.144660 / 0.176557 (-0.031897) | 0.188156 / 0.737135 (-0.548979) | 0.149875 / 0.296338 (-0.146463) |

### 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.502218 / 0.215209 (0.287009) | 5.004486 / 2.077655 (2.926832) | 2.420379 / 1.504120 (0.916259) | 2.194671 / 1.541195 (0.653476) | 2.306376 / 1.468490 (0.837886) | 0.856623 / 4.584777 (-3.728154) | 4.963211 / 3.745712 (1.217499) | 2.517965 / 5.269862 (-2.751896) | 1.743880 / 4.565676 (-2.821797) | 0.105270 / 0.424275 (-0.319005) | 0.014725 / 0.007607 (0.007118) | 0.621934 / 0.226044 (0.395890) | 6.183827 / 2.268929 (3.914898) | 2.945868 / 55.444624 (-52.498757) | 2.557676 / 6.876477 (-4.318801) | 2.622282 / 2.142072 (0.480210) | 1.011647 / 4.805227 (-3.793580) | 0.199573 / 6.500664 (-6.301091) | 0.076283 / 0.075469 (0.000814) |

### 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.518813 / 1.841788 (-0.322975) | 18.833017 / 8.074308 (10.758709) | 16.095249 / 10.191392 (5.903857) | 0.196667 / 0.680424 (-0.483757) | 0.022060 / 0.534201 (-0.512141) | 0.537802 / 0.579283 (-0.041481) | 0.523676 / 0.434364 (0.089312) | 0.629387 / 0.540337 (0.089049) | 0.738042 / 1.386936 (-0.648894) |

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

Show benchmarks

PyArrow==6.0.0

Show updated benchmarks!

### 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.008608 / 0.011353 (-0.002745) | 0.004553 / 0.011008 (-0.006455) | 0.100031 / 0.038508 (0.061523) | 0.029498 / 0.023109 (0.006389) | 0.306913 / 0.275898 (0.031015) | 0.367369 / 0.323480 (0.043889) | 0.006883 / 0.007986 (-0.001103) | 0.004768 / 0.004328 (0.000440) | 0.077424 / 0.004250 (0.073173) | 0.034005 / 0.037052 (-0.003047) | 0.317772 / 0.258489 (0.059283) | 0.356859 / 0.293841 (0.063018) | 0.033717 / 0.128546 (-0.094829) | 0.011386 / 0.075646 (-0.064260) | 0.322832 / 0.419271 (-0.096439) | 0.043930 / 0.043533 (0.000397) | 0.308087 / 0.255139 (0.052948) | 0.338349 / 0.283200 (0.055149) | 0.094780 / 0.141683 (-0.046903) | 1.463454 / 1.452155 (0.011300) | 1.495055 / 1.492716 (0.002338) |

### 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.191039 / 0.018006 (0.173033) | 0.414650 / 0.000490 (0.414160) | 0.002435 / 0.000200 (0.002235) | 0.000075 / 0.000054 (0.000021) |

### Benchmark: benchmark_indices_mapping.json

| metric | select | shard | shuffle | sort | train_test_split |
|--------|---|---|---|---|---|
| new / old (diff) | 0.023871 / 0.037411 (-0.013540) | 0.097140 / 0.014526 (0.082614) | 0.105914 / 0.176557 (-0.070643) | 0.147375 / 0.737135 (-0.589760) | 0.107985 / 0.296338 (-0.188354) |

### 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.420174 / 0.215209 (0.204965) | 4.208354 / 2.077655 (2.130700) | 1.904568 / 1.504120 (0.400448) | 1.687406 / 1.541195 (0.146212) | 1.723901 / 1.468490 (0.255411) | 0.693554 / 4.584777 (-3.891223) | 3.445474 / 3.745712 (-0.300238) | 1.904919 / 5.269862 (-3.364943) | 1.284378 / 4.565676 (-3.281298) | 0.082539 / 0.424275 (-0.341736) | 0.012490 / 0.007607 (0.004883) | 0.527778 / 0.226044 (0.301733) | 5.300766 / 2.268929 (3.031838) | 2.324666 / 55.444624 (-53.119958) | 1.977166 / 6.876477 (-4.899311) | 2.054396 / 2.142072 (-0.087677) | 0.820966 / 4.805227 (-3.984261) | 0.148584 / 6.500664 (-6.352080) | 0.063618 / 0.075469 (-0.011851) |

### 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.188075 / 1.841788 (-0.653712) | 13.706950 / 8.074308 (5.632642) | 13.725122 / 10.191392 (3.533730) | 0.167379 / 0.680424 (-0.513045) | 0.028729 / 0.534201 (-0.505472) | 0.395373 / 0.579283 (-0.183910) | 0.403604 / 0.434364 (-0.030760) | 0.464290 / 0.540337 (-0.076047) | 0.553792 / 1.386936 (-0.833144) |

PyArrow==latest

Show updated benchmarks!

### 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.006565 / 0.011353 (-0.004787) | 0.004588 / 0.011008 (-0.006420) | 0.077312 / 0.038508 (0.038804) | 0.027348 / 0.023109 (0.004239) | 0.367753 / 0.275898 (0.091855) | 0.403250 / 0.323480 (0.079770) | 0.005201 / 0.007986 (-0.002785) | 0.004695 / 0.004328 (0.000366) | 0.076203 / 0.004250 (0.071953) | 0.039388 / 0.037052 (0.002336) | 0.374418 / 0.258489 (0.115929) | 0.413623 / 0.293841 (0.119782) | 0.031731 / 0.128546 (-0.096815) | 0.011644 / 0.075646 (-0.064002) | 0.086339 / 0.419271 (-0.332932) | 0.048902 / 0.043533 (0.005369) | 0.352064 / 0.255139 (0.096925) | 0.386637 / 0.283200 (0.103437) | 0.093662 / 0.141683 (-0.048021) | 1.479863 / 1.452155 (0.027709) | 1.562475 / 1.492716 (0.069758) |

### 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.231874 / 0.018006 (0.213867) | 0.402185 / 0.000490 (0.401695) | 0.005252 / 0.000200 (0.005052) | 0.000086 / 0.000054 (0.000032) |

### Benchmark: benchmark_indices_mapping.json

| metric | select | shard | shuffle | sort | train_test_split |
|--------|---|---|---|---|---|
| new / old (diff) | 0.025402 / 0.037411 (-0.012010) | 0.099896 / 0.014526 (0.085370) | 0.106365 / 0.176557 (-0.070192) | 0.143309 / 0.737135 (-0.593827) | 0.112311 / 0.296338 (-0.184027) |

### 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.447637 / 0.215209 (0.232428) | 4.469337 / 2.077655 (2.391682) | 2.164332 / 1.504120 (0.660212) | 1.957826 / 1.541195 (0.416631) | 1.984580 / 1.468490 (0.516090) | 0.702909 / 4.584777 (-3.881868) | 3.361725 / 3.745712 (-0.383987) | 2.818102 / 5.269862 (-2.451760) | 1.589815 / 4.565676 (-2.975862) | 0.083647 / 0.424275 (-0.340628) | 0.012502 / 0.007607 (0.004895) | 0.545578 / 0.226044 (0.319534) | 5.480894 / 2.268929 (3.211966) | 2.605599 / 55.444624 (-52.839026) | 2.253444 / 6.876477 (-4.623032) | 2.289818 / 2.142072 (0.147746) | 0.803680 / 4.805227 (-4.001547) | 0.151870 / 6.500664 (-6.348794) | 0.066610 / 0.075469 (-0.008859) |

### 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.327390 / 1.841788 (-0.514398) | 14.046936 / 8.074308 (5.972628) | 13.643169 / 10.191392 (3.451777) | 0.128223 / 0.680424 (-0.552201) | 0.016941 / 0.534201 (-0.517260) | 0.383887 / 0.579283 (-0.195396) | 0.383891 / 0.434364 (-0.050473) | 0.440191 / 0.540337 (-0.100146) | 0.525357 / 1.386936 (-0.861579) |

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

Yea there must have been an update in another package that unconstrained the protobuf dependency - idk which one though

It is `tensorboard`. I have reported the issue to `tensorflow`:
- https://github.com/tensorflow/tensorflow/issues/59665

fix https://github.com/huggingface/datasets/actions/runs/4156059127/jobs/7189576331


Thanks for the quick review! I updated the code with your suggestion

Thanks for the quick review @albertvillanova! I updated the code with your suggestions

Show benchmarks

PyArrow==8.0.0

Show updated benchmarks!

### 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.008577 / 0.011353 (-0.002776) | 0.005714 / 0.011008 (-0.005294) | 0.114718 / 0.038508 (0.076210) | 0.039799 / 0.023109 (0.016690) | 0.387530 / 0.275898 (0.111632) | 0.395739 / 0.323480 (0.072259) | 0.006775 / 0.007986 (-0.001211) | 0.006280 / 0.004328 (0.001952) | 0.086470 / 0.004250 (0.082220) | 0.054424 / 0.037052 (0.017371) | 0.361989 / 0.258489 (0.103500) | 0.424678 / 0.293841 (0.130837) | 0.043081 / 0.128546 (-0.085465) | 0.013903 / 0.075646 (-0.061743) | 0.397625 / 0.419271 (-0.021647) | 0.059789 / 0.043533 (0.016256) | 0.375195 / 0.255139 (0.120056) | 0.403724 / 0.283200 (0.120524) | 0.121470 / 0.141683 (-0.020213) | 1.734496 / 1.452155 (0.282341) | 1.820479 / 1.492716 (0.327763) |

### 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.239672 / 0.018006 (0.221665) | 0.499373 / 0.000490 (0.498883) | 0.005034 / 0.000200 (0.004834) | 0.000099 / 0.000054 (0.000045) |

### Benchmark: benchmark_indices_mapping.json

| metric | select | shard | shuffle | sort | train_test_split |
|--------|---|---|---|---|---|
| new / old (diff) | 0.033000 / 0.037411 (-0.004411) | 0.130930 / 0.014526 (0.116404) | 0.151690 / 0.176557 (-0.024866) | 0.211839 / 0.737135 (-0.525296) | 0.148727 / 0.296338 (-0.147612) |

### 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.480592 / 0.215209 (0.265382) | 4.809700 / 2.077655 (2.732046) | 2.232414 / 1.504120 (0.728294) | 2.035432 / 1.541195 (0.494237) | 2.115991 / 1.468490 (0.647501) | 0.817841 / 4.584777 (-3.766936) | 4.718035 / 3.745712 (0.972323) | 4.107102 / 5.269862 (-1.162759) | 2.166838 / 4.565676 (-2.398839) | 0.102207 / 0.424275 (-0.322068) | 0.014686 / 0.007607 (0.007079) | 0.599922 / 0.226044 (0.373877) | 5.985840 / 2.268929 (3.716912) | 2.769199 / 55.444624 (-52.675425) | 2.427095 / 6.876477 (-4.449382) | 2.586666 / 2.142072 (0.444593) | 0.987650 / 4.805227 (-3.817578) | 0.199419 / 6.500664 (-6.301245) | 0.076710 / 0.075469 (0.001240) |

### 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.454509 / 1.841788 (-0.387278) | 18.267849 / 8.074308 (10.193541) | 16.701880 / 10.191392 (6.510488) | 0.204225 / 0.680424 (-0.476199) | 0.020295 / 0.534201 (-0.513906) | 0.504254 / 0.579283 (-0.075029) | 0.535071 / 0.434364 (0.100707) | 0.611825 / 0.540337 (0.071488) | 0.697289 / 1.386936 (-0.689647) |

PyArrow==latest

Show updated benchmarks!

### 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.009141 / 0.011353 (-0.002211) | 0.005987 / 0.011008 (-0.005021) | 0.092003 / 0.038508 (0.053495) | 0.043239 / 0.023109 (0.020130) | 0.400425 / 0.275898 (0.124527) | 0.464849 / 0.323480 (0.141369) | 0.008256 / 0.007986 (0.000270) | 0.006251 / 0.004328 (0.001923) | 0.095263 / 0.004250 (0.091013) | 0.057899 / 0.037052 (0.020847) | 0.402899 / 0.258489 (0.144410) | 0.477411 / 0.293841 (0.183570) | 0.044122 / 0.128546 (-0.084424) | 0.014158 / 0.075646 (-0.061489) | 0.116354 / 0.419271 (-0.302917) | 0.061045 / 0.043533 (0.017512) | 0.411635 / 0.255139 (0.156497) | 0.466281 / 0.283200 (0.183082) | 0.129423 / 0.141683 (-0.012260) | 1.799790 / 1.452155 (0.347635) | 2.004578 / 1.492716 (0.511862) |

### 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.224012 / 0.018006 (0.206006) | 0.502972 / 0.000490 (0.502482) | 0.003560 / 0.000200 (0.003360) | 0.000110 / 0.000054 (0.000056) |

### Benchmark: benchmark_indices_mapping.json

| metric | select | shard | shuffle | sort | train_test_split |
|--------|---|---|---|---|---|
| new / old (diff) | 0.034794 / 0.037411 (-0.002618) | 0.139646 / 0.014526 (0.125120) | 0.144330 / 0.176557 (-0.032226) | 0.202528 / 0.737135 (-0.534607) | 0.151561 / 0.296338 (-0.144777) |

### 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.504343 / 0.215209 (0.289133) | 5.050690 / 2.077655 (2.973035) | 2.433107 / 1.504120 (0.928987) | 2.197443 / 1.541195 (0.656248) | 2.331225 / 1.468490 (0.862734) | 0.834066 / 4.584777 (-3.750711) | 4.837648 / 3.745712 (1.091936) | 4.105672 / 5.269862 (-1.164189) | 2.281557 / 4.565676 (-2.284120) | 0.102257 / 0.424275 (-0.322018) | 0.014425 / 0.007607 (0.006818) | 0.629290 / 0.226044 (0.403245) | 6.251513 / 2.268929 (3.982585) | 2.959012 / 55.444624 (-52.485613) | 2.570031 / 6.876477 (-4.306446) | 2.657525 / 2.142072 (0.515453) | 1.002861 / 4.805227 (-3.802367) | 0.199326 / 6.500664 (-6.301338) | 0.078428 / 0.075469 (0.002958) |

### 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.579587 / 1.841788 (-0.262201) | 18.567509 / 8.074308 (10.493201) | 17.162144 / 10.191392 (6.970752) | 0.193460 / 0.680424 (-0.486964) | 0.020819 / 0.534201 (-0.513382) | 0.501929 / 0.579283 (-0.077354) | 0.508039 / 0.434364 (0.073675) | 0.582656 / 0.540337 (0.042319) | 0.693624 / 1.386936 (-0.693312) |

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

Fixes #5428

Allow loading/saving of FAISS index using fsspec:
1. Simply use BufferedIOWriter/Reader to Read/Write indices on fsspec stream.
2. Needed `mockfs` in the test, so I took it out of the `TestCase`. Let me know if that makes sense.

I can work on the documentation once the code changes are approved.


TypeError: Couldn't cast array of type string to null

Thanks for reporting, @TJ-Solergibert.

We cannot access your Colab notebook: `There was an error loading this notebook. Ensure that the file is accessible and try again.`
Could you please make it publicly accessible?

I swear it's public, I've checked the settings and I've been able to open it in incognito mode.

Notebook: https://colab.research.google.com/drive/1JCrS7FlGfu_kFqChMrwKZ_bpabnIMqbP?usp=sharing

Anyway, this is the code to reproduce the error:

```python3
from datasets import ClassLabel
from datasets import load_dataset

europarl_ds = load_dataset("tj-solergibert/Europarl-ST")

source_lang = "nl"
languages = list(europarl_ds["train"][0]["transcriptions"].keys())
ClassLabels = ClassLabel(num_classes = len(languages), names = languages)

def map_label2id(example):
    example['dest_lang'] = ClassLabels.str2int(example['dest_lang'])
    return example

def unfold_transcriptions(example):
  for lang in languages:
    example[lang] = example["transcriptions"][lang]
  return example

def unroll(batch, src_lang, dest_langs):
  source_t, dest_t, dest_l = [], [], []
  for lang in dest_langs:
    source_t += batch[src_lang]
    dest_t += batch[lang]
    dest_l += [lang]
  return_dict = {"source_text": source_t, "dest_text": dest_t, "dest_lang": dest_l}
  return return_dict

def preprocess_split(ds_split, src_lang):
  dest_langs = [x for x in languages if x != src_lang]

  ds_split = ds_split.map(unroll, fn_kwargs= {"src_lang": src_lang, "dest_langs": dest_langs}, batched = True, batch_size = 1, remove_columns= list(languages))
  ds_split = ds_split.filter(lambda x: x["source_text"] != None and x["dest_text"] != None) # Remove incomplete translations
  ds_split = ds_split.filter(lambda x: x["source_text"] != "None" and x["dest_text"] != "None")
  ds_split = ds_split.map(map_label2id)
  ds_split = ds_split.cast_column("dest_lang", ClassLabels)
  return ds_split

def reset_cortas(example):
  for lang in languages:
    if isinstance(example[lang], str):
      if example[lang].isnumeric () or len(example[lang]) <= 5:
        example[lang] = "None"
  return example

def clean_dataset(dataset):
  # Remove columns
  dataset = dataset.remove_columns(["original_speech", "original_language", "audio_path", "segment_start", "segment_end"])
  # Unfold
  dataset = dataset.map(unfold_transcriptions, remove_columns = ["transcriptions"])
  dataset = dataset.map(reset_cortas)
  return dataset

processed_europarl = clean_dataset(europarl_ds["test"])
new_train_ds = preprocess_split(processed_europarl, 'nl')
```

Thanks, @TJ-Solergibert. I can access your notebook now. Maybe it was just a temporary issue.

At first sight, it seems something related to your data: maybe some of the examples do not have all the transcriptions for all the languages. Then, some of them are null when unrolled. And when trying to concatenate with the other rows containing strings, the cast issue is raised (the arrays to be concatenated have different types).

Do you think this could be the case?

See, in this example, "nl" and "ro" transcripts are null:
```python
>>> europarl_ds["test"][:1]
{'original_speech': ['− Señor Presidente, en primer lugar, quisiera felicitar al señor Seeber por el trabajo realizado, porque en su informe se recogen muchas de las preocupaciones manifestadas en esta'],
 'original_language': ['es'],
 'audio_path': ['es/audios/en.20081008.24.3-238.m4a'],
 'segment_start': [0.6200000047683716],
 'segment_end': [11.319999694824219],
 'transcriptions': [{'de': '− Herr Präsident! Zunächst möchte ich Richard Seeber zu der von ihm geleisteten Arbeit gratulieren, denn sein Bericht greift viele der in diesem Haus zum Ausdruck gebrachten Anliegen',
   'en': '− Mr President, firstly I would like to congratulate Mr Seeber on the work he has done, because his report picks up many of the concerns expressed in this',
   'es': '− Señor Presidente, en primer lugar, quisiera felicitar al señor Seeber por el trabajo realizado, porque en su informe se recogen muchas de las preocupaciones manifestadas en esta',
   'fr': '− Monsieur le Président, je voudrais tout d ’ abord féliciter M. Seeber pour le travail qu ’ il a effectué, parce que son rapport reprend beaucoup des inquiétudes exprimées au sein de cette',
   'it': "− Signor Presidente, mi congratulo innanzi tutto con l'onorevole Seeber per il lavoro svolto, perché la sua relazione accoglie molti dei timori espressi da quest'Aula",
   'nl': None,
   'pl': '− Panie przewodniczący! Po pierwsze chciałabym pogratulować panu posłowi Seeberowi wykonanej pracy, ponieważ jego sprawozdanie podejmuje szereg podnoszonych w tej Izbie',
   'pt': '− Senhor Presidente, começo por felicitar o senhor deputado Seeber pelo trabalho que desenvolveu em torno deste relatório, que retoma muitas das preocupações expressas nesta',
   'ro': None}]}
```
```python
>>> processed_europarl[0]
{'de': '− Herr Präsident! Zunächst möchte ich Richard Seeber zu der von ihm geleisteten Arbeit gratulieren, denn sein Bericht greift viele der in diesem Haus zum Ausdruck gebrachten Anliegen',
 'en': '− Mr President, firstly I would like to congratulate Mr Seeber on the work he has done, because his report picks up many of the concerns expressed in this',
 'es': '− Señor Presidente, en primer lugar, quisiera felicitar al señor Seeber por el trabajo realizado, porque en su informe se recogen muchas de las preocupaciones manifestadas en esta',
 'fr': '− Monsieur le Président, je voudrais tout d ’ abord féliciter M. Seeber pour le travail qu ’ il a effectué, parce que son rapport reprend beaucoup des inquiétudes exprimées au sein de cette',
 'it': "− Signor Presidente, mi congratulo innanzi tutto con l'onorevole Seeber per il lavoro svolto, perché la sua relazione accoglie molti dei timori espressi da quest'Aula",
 'nl': None,
 'pl': '− Panie przewodniczący! Po pierwsze chciałabym pogratulować panu posłowi Seeberowi wykonanej pracy, ponieważ jego sprawozdanie podejmuje szereg podnoszonych w tej Izbie',
 'pt': '− Senhor Presidente, começo por felicitar o senhor deputado Seeber pelo trabalho que desenvolveu em torno deste relatório, que retoma muitas das preocupações expressas nesta',
 'ro': None}
```

You can fix this issue by forcing the cast of None to str by hand:
- If you replace this line:
```python
source_t += batch[src_lang]
```
- With this line (because the batch size is 1):
```python
source_t += [str(batch[src_lang][0])]
```
- Or with this line (if the batch size were larger than 1):
```python
source_t += [str(text) for text in batch[src_lang]]
```

Problem solved! Thanks @albertvillanova, now I have even increased the batch size and it's crazy fast :rocket: !

### Describe the bug

Processing a dataset I alredy uploaded to the Hub (https://huggingface.co/datasets/tj-solergibert/Europarl-ST) I found that for some splits and some languages (test split, source_lang = "nl") after applying a map function I get the mentioned error.

I alredy tried reseting the shorter strings (reset_cortas function). It only happends with NL, PL, RO and PT. It does not make sense since when processing the other languages I also use the corpus of those that fail and it does not cause any errors.

I suspect that the error may be in this direction:

We use cast_array_to_feature to support casting to custom types like Audio and Image # Also, when trying type "string", we don't want to convert integers or floats to "string". # We only do it if trying_type is False - since this is what the user asks for.

### Steps to reproduce the bug

Here I link a colab notebook to reproduce the error:

https://colab.research.google.com/drive/1JCrS7FlGfu_kFqChMrwKZ_bpabnIMqbP?authuser=1#scrollTo=FBAvlhMxIzpA

### Expected behavior

Data processing does not fail. A correct example can be seen here: https://huggingface.co/datasets/tj-solergibert/Europarl-ST-processed-mt-en

### Environment info

- `datasets` version: 2.9.0
- Platform: Linux-5.10.147+-x86_64-with-glibc2.29
- Python version: 3.8.10
- PyArrow version: 9.0.0
- Pandas version: 1.3.5


[INVALID PR]

Hi to whoever is reading this! 🤗

## What's in this PR?

~~Basically, I've removed the 🤗`datasets` installation as `python -m pip install ".[quality]" in the `check_code_quality` job in `.github/workflows/ci.yaml`, as we don't need to install the whole package to run the CI, unless that's done on purpose e.g. to check that the Python package installation succeeds before running the tests over the matrix of os?~~

~~So I just wanted to check whether the time was reduced doing this (which I assume it will), plus whether this is something that can be improved, or just discarded in case you're also using that step to make sure that the package can be installed.~~

## What's missing?

~~I was just wondering whether you consider replacing `isort` and `flake8` with `ruff` (if possible), since it's way faster, more information at [`ruff`](https://github.com/charliermarsh/ruff). Before creating this PR the average time of the `check_code_quality` job was around 40s.~~

## Edit

Sorry for the inconvenience this may have caused, didn't realise that the config is defined in `setup.cfg` and `pyproject.toml`, so running those without installing the Python package leads to failure, my bad 😞


Checking that split name is correct happens only after the data is downloaded

bug

Something isn't working

### Describe the bug

Verification of split names (=indexing data by split) happens after downloading the data. So when the split name is incorrect, users learn about that only after the data is fully downloaded, for large datasets it might take a lot of time.

### Steps to reproduce the bug

Load any dataset with random split name, for example:
```python
from datasets import load_dataset

load_dataset("mozilla-foundation/common_voice_11_0", "en", split="blabla")
```
and the download will start smoothly, despite there is no split named "blabla".

### Expected behavior

Raise error when split name is incorrect.

### Environment info

`datasets==2.9.1.dev0`


Minor changes in JAX-formatting docstrings & type-hints

P.S. For more context, I'm currently exploring the integration of 🤗`datasets` with JAX, so in case you need any help or want me to try something specific just let me know! (`jnp.asarray`/`jnp.array(..., copy=False)` still no zero-copy 😭)

> Hi ! Thanks for improving this :)

Glad to help, @lhoestq! Also, regarding the questions in the `## What's missing?` can I have your input? Thanks 🤗

Whoops forgot to reply to these matters - sorry x)

Yea a JAX guide would be welcome in the documentation ! This can be done in a separate PR if you want :)

Pyarrow is always imported with `datasets`, so it doesn't really matter if it's under TYPE_CHECKING or not.

Regarding the license : yes indeed it should be in every file, thanks for reporting.

No big preference between jnp.array and jnp.asarray, unless one offers better performance

> Whoops forgot to reply to these matters - sorry x)
>
> Yea a JAX guide would be welcome in the documentation ! This can be done in a separate PR if you want :)
>
> Pyarrow is always imported with `datasets`, so it doesn't really matter if it's under TYPE_CHECKING or not.
>
> Regarding the license : yes indeed it should be in every file, thanks for reporting.
>
> No big preference between jnp.array and jnp.asarray, unless one offers better performance

Cool @lhoestq thanks for the input there!

1. I can create a separate PR for JAX-format usage
2. Regarding that, makes sense, we can just not put it there, unless it's more clear that in that file `pyarrow` is just required for typing?
3. Do you want me to add the License? In this PR? In a separate one?
4. Ideally `jnp.asarray` is similar to `np.asarray` which in the case of `numpy` tends to be more efficient as it does zero-copy when possible, while `np.array` has `copy=True` by default, anyway as I mentioned before (and as you already know) the copy from `numpy` to `jax` is not zero-copy, while the other way around (`jax` to `numpy`) it is

Thanks, feel free to create separate PRs for the docs and the license.

I guess you can move the `pyarrow` import back to where it was for consistency with the other files and we can merge this one ;)

> Thanks, feel free to create separate PRs for the docs and the license.
>
> I guess you can move the `pyarrow` import back to where it was for consistency with the other files and we can merge this one ;)

Cool thanks I'll do that! 👍🏻

Actually I just checked and there are still tens of thousands of users with jax 0.3.25 - so we need to support older versions as well. I guess it comes from `transformers` which doesn't support jax 0.4 (and doesn't want to until the jax team stops breaking the lib all the time).

Could you make sure your changes work with older versions as well ? Sorry for not spotting this earlier.
If we have `"jax>=0.2.8,!=0.3.2,<=0.4.3"` that'b be nice, and we can update the latest supported release from time to time.

In the CI you can add `jax==0.2.8` for the `deps-minimum` job, and use `jax~=0.4.1` for the `deps-latest`.

> Actually I just checked and there are still tens of thousands of users with jax 0.3.25 - so we need to support older versions as well. I guess it comes from `transformers` which doesn't support jax 0.4 (and doesn't want to until the jax team stops breaking the lib all the time).
>
> Could you make sure your changes work with older versions as well ? Sorry for not spotting this earlier. If we have `"jax>=0.2.8,!=0.3.2,<=0.4.3"` that'b be nice, and we can update the latest supported release from time to time.
>
> In the CI you can add `jax==0.2.8` for the `deps-minimum` job, and use `jax~=0.4.1` for the `deps-latest`.

Ok, didn't know that @lhoestq thanks for the detailed context! Sure, I'll update it and make sure it's also compatible with older versions.

Oops forgot to add you as co-author of the last commit @lhoestq my bad 😞

So it should be fixed right now @lhoestq! The thing is that `jax` doesn't provide support for Python 3.7 due to its EOL next June (more information at https://endoflife.date/python)...

Anyway, I can confirm that `jax.Array` type works with 0.3.25 and that the following code works fine:

```python
import jax
import jax.numpy as jnp

x = jnp.ones((1, 10), dtype=jnp.float32)  # Is a `jnp.DeviceArray`
assert isinstance(x, jax.Array)  # Is `True`
```

So we can still use 0.3.25 as the maximum supported version, as well as 0.3.6 for `jaxlib` so as to be consistent with 🤗`transformers`.

Thanks for your comments @lhoestq those were really useful!

Sorry for the spam, pinning versions leads to failure runs (not related to the type-hinting); I'll check that locally instead of here to avoid spam... Not pinning the dependencies work but I'll check the minimum required versions for both `jax` and `jaxlib` in Python 3.7

> Cool ! Thanks for trying to make the CI support it, but it's maybe not worth spending more time on this for now ^^
>
> merging :)

Do you want me to work on the CI in a separate branch? Thanks for merging and for your help as always :)

> Do you want me to work on the CI in a separate branch? Thanks for merging and for your help as always :)

In the end I think we can keep it as is since we didn't modify the core code for jax. Maybe later if we do further changes and need to make sure we don't break anything ;) For example when we decide to add support for more recent versions

Show benchmarks

PyArrow==6.0.0

Show updated benchmarks!

### 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.010798 / 0.011353 (-0.000555) | 0.005690 / 0.011008 (-0.005318) | 0.116840 / 0.038508 (0.078332) | 0.041376 / 0.023109 (0.018266) | 0.345616 / 0.275898 (0.069718) | 0.413914 / 0.323480 (0.090434) | 0.009237 / 0.007986 (0.001252) | 0.004490 / 0.004328 (0.000162) | 0.085833 / 0.004250 (0.081582) | 0.050231 / 0.037052 (0.013179) | 0.367276 / 0.258489 (0.108787) | 0.393735 / 0.293841 (0.099894) | 0.043775 / 0.128546 (-0.084772) | 0.013215 / 0.075646 (-0.062432) | 0.391020 / 0.419271 (-0.028252) | 0.055102 / 0.043533 (0.011569) | 0.360333 / 0.255139 (0.105194) | 0.370531 / 0.283200 (0.087331) | 0.115484 / 0.141683 (-0.026199) | 1.694779 / 1.452155 (0.242625) | 1.756249 / 1.492716 (0.263532) |

### 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.230508 / 0.018006 (0.212501) | 0.478681 / 0.000490 (0.478191) | 0.010305 / 0.000200 (0.010105) | 0.000147 / 0.000054 (0.000093) |

### Benchmark: benchmark_indices_mapping.json

| metric | select | shard | shuffle | sort | train_test_split |
|--------|---|---|---|---|---|
| new / old (diff) | 0.030953 / 0.037411 (-0.006459) | 0.124320 / 0.014526 (0.109794) | 0.140417 / 0.176557 (-0.036140) | 0.189522 / 0.737135 (-0.547613) | 0.143635 / 0.296338 (-0.152704) |

### 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.485995 / 0.215209 (0.270786) | 4.799668 / 2.077655 (2.722014) | 2.195655 / 1.504120 (0.691535) | 1.940073 / 1.541195 (0.398879) | 2.053853 / 1.468490 (0.585363) | 0.825399 / 4.584777 (-3.759378) | 4.522180 / 3.745712 (0.776468) | 2.484626 / 5.269862 (-2.785236) | 1.727617 / 4.565676 (-2.838059) | 0.098808 / 0.424275 (-0.325467) | 0.014753 / 0.007607 (0.007146) | 0.606798 / 0.226044 (0.380754) | 5.918090 / 2.268929 (3.649162) | 2.668124 / 55.444624 (-52.776500) | 2.300447 / 6.876477 (-4.576030) | 2.411203 / 2.142072 (0.269130) | 0.999826 / 4.805227 (-3.805401) | 0.193683 / 6.500664 (-6.306981) | 0.069341 / 0.075469 (-0.006129) |

### 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.455816 / 1.841788 (-0.385972) | 17.176476 / 8.074308 (9.102168) | 16.359100 / 10.191392 (6.167708) | 0.199669 / 0.680424 (-0.480755) | 0.033456 / 0.534201 (-0.500745) | 0.512478 / 0.579283 (-0.066805) | 0.526350 / 0.434364 (0.091986) | 0.637669 / 0.540337 (0.097332) | 0.753821 / 1.386936 (-0.633115) |

PyArrow==latest

Show updated benchmarks!

### 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.008176 / 0.011353 (-0.003177) | 0.005862 / 0.011008 (-0.005147) | 0.086123 / 0.038508 (0.047615) | 0.037144 / 0.023109 (0.014035) | 0.398328 / 0.275898 (0.122430) | 0.439126 / 0.323480 (0.115647) | 0.006455 / 0.007986 (-0.001531) | 0.004575 / 0.004328 (0.000246) | 0.083396 / 0.004250 (0.079146) | 0.052827 / 0.037052 (0.015775) | 0.401039 / 0.258489 (0.142550) | 0.441374 / 0.293841 (0.147533) | 0.041671 / 0.128546 (-0.086875) | 0.014098 / 0.075646 (-0.061548) | 0.100873 / 0.419271 (-0.318398) | 0.058690 / 0.043533 (0.015157) | 0.395817 / 0.255139 (0.140678) | 0.409226 / 0.283200 (0.126026) | 0.119804 / 0.141683 (-0.021879) | 1.704583 / 1.452155 (0.252428) | 1.782527 / 1.492716 (0.289811) |

### 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.255166 / 0.018006 (0.237160) | 0.485091 / 0.000490 (0.484601) | 0.007458 / 0.000200 (0.007258) | 0.000116 / 0.000054 (0.000061) |

### Benchmark: benchmark_indices_mapping.json

| metric | select | shard | shuffle | sort | train_test_split |
|--------|---|---|---|---|---|
| new / old (diff) | 0.034531 / 0.037411 (-0.002880) | 0.134332 / 0.014526 (0.119806) | 0.144944 / 0.176557 (-0.031613) | 0.199352 / 0.737135 (-0.537783) | 0.152243 / 0.296338 (-0.144095) |

### 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.495361 / 0.215209 (0.280152) | 4.895144 / 2.077655 (2.817489) | 2.350419 / 1.504120 (0.846299) | 2.112131 / 1.541195 (0.570937) | 2.234469 / 1.468490 (0.765978) | 0.815862 / 4.584777 (-3.768915) | 4.531638 / 3.745712 (0.785926) | 2.405186 / 5.269862 (-2.864676) | 1.559020 / 4.565676 (-3.006656) | 0.100432 / 0.424275 (-0.323843) | 0.014217 / 0.007607 (0.006610) | 0.614622 / 0.226044 (0.388577) | 5.984541 / 2.268929 (3.715613) | 2.929897 / 55.444624 (-52.514727) | 2.484010 / 6.876477 (-4.392467) | 2.533538 / 2.142072 (0.391466) | 0.972119 / 4.805227 (-3.833108) | 0.193630 / 6.500664 (-6.307034) | 0.073694 / 0.075469 (-0.001775) |

### 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.503725 / 1.841788 (-0.338063) | 17.421529 / 8.074308 (9.347221) | 15.686433 / 10.191392 (5.495041) | 0.216688 / 0.680424 (-0.463736) | 0.020929 / 0.534201 (-0.513272) | 0.512523 / 0.579283 (-0.066760) | 0.499878 / 0.434364 (0.065514) | 0.639238 / 0.540337 (0.098900) | 0.769598 / 1.386936 (-0.617338) |

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

> > Do you want me to work on the CI in a separate branch? Thanks for merging and for your help as always :)
>
> In the end I think we can keep it as is since we didn't modify the core code for jax. Maybe later if we do further changes and need to make sure we don't break anything ;) For example when we decide to add support for more recent versions

Makes sense, thank you @lhoestq!

Hi to whoever is reading this! 🤗

## What's in this PR?

I was exploring the code regarding the `JaxFormatter` implemented in 🤗`datasets`, and found some things that IMO could be changed. Those are mainly regarding the docstrings and the type-hints based on `jax`'s 0.4.1 release where `jax.Array` was introduced as the default type for JAX-arrays (instead of `jnp.DeviceArray`, `jnp.SharedDeviceArray`, and `jnp.GlobalDeviceArray`). Even though `isinstance(..., jax.Array)` also works with lower versions such as e.g. `0.3.25`.

More information about the latter at [`jax` v0.4.1 - Release Notes](https://github.com/google/jax/releases/tag/jax-v0.4.1) and [jax.Array migration - JAX documentation](https://jax.readthedocs.io/en/latest/jax_array_migration.html).

## What's missing?

* Do you want me to write an entry in the documentation on how to use 🤗`datasets` with JAX as https://huggingface.co/docs/datasets/use_with_pytorch with PyTorch?
* Do we need to actually include `pyarrow` under the `TYPE_CHECKING` when needed? I just did it for JAX, but if we are OK with that, I can do that with the rest of the formatters, just LMK.
* Should the License header be included in `datasets.formatting.np_formatter`? If so, do I include the one from 2020 e.g. https://github.com/huggingface/datasets/blob/b065547654efa0ec633cf373ac1512884c68b2e1/src/datasets/formatting/tf_formatter.py#L1-L13
* Is there any reason why `jnp.array` is being used instead of `jnp.asarray`? There's no difference between both, just that `jnp.asarray` has `copy=False` as default, even though `numpy` to `jax.numpy` conversion is not zero-copy, but just asking :)


Fix bug when casting empty array to class labels

_The documentation is not available anymore as the PR was closed or merged._

Fix https://github.com/huggingface/datasets/issues/5520.


ClassLabel.cast_storage raises TypeError when called on an empty IntegerArray

### Describe the bug

`ClassLabel.cast_storage` raises `TypeError` when called on an empty `IntegerArray`.

### Steps to reproduce the bug

Minimal steps:
```python
import pyarrow as pa
from datasets import ClassLabel

ClassLabel(names=['foo', 'bar']).cast_storage(pa.array([], pa.int64()))
```

In practice, this bug arises in situations like the one below:
```python
from datasets import ClassLabel, Dataset, Features, Sequence

dataset = Dataset.from_dict({'labels': [[], []]}, features=Features({'labels': Sequence(ClassLabel(names=['foo', 'bar']))}))

# this raises TypeError
dataset.map(batched=True, batch_size=1)
```

### Expected behavior

`ClassLabel.cast_storage` should return an empty Int64Array.

### Environment info

- `datasets` version: 2.9.1.dev0
- Platform: Linux-4.15.0-1032-aws-x86_64-with-glibc2.27
- Python version: 3.10.6
- PyArrow version: 11.0.0
- Pandas version: 1.5.3


Lint code with `ruff`

Show benchmarks

PyArrow==6.0.0

Show updated benchmarks!

### 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.009729 / 0.011353 (-0.001624) | 0.005342 / 0.011008 (-0.005666) | 0.100194 / 0.038508 (0.061686) | 0.036391 / 0.023109 (0.013282) | 0.294163 / 0.275898 (0.018264) | 0.364117 / 0.323480 (0.040637) | 0.008231 / 0.007986 (0.000246) | 0.005954 / 0.004328 (0.001626) | 0.076484 / 0.004250 (0.072234) | 0.045028 / 0.037052 (0.007976) | 0.308163 / 0.258489 (0.049674) | 0.339473 / 0.293841 (0.045632) | 0.039268 / 0.128546 (-0.089279) | 0.012357 / 0.075646 (-0.063289) | 0.334176 / 0.419271 (-0.085096) | 0.049502 / 0.043533 (0.005969) | 0.294134 / 0.255139 (0.038995) | 0.319370 / 0.283200 (0.036170) | 0.113040 / 0.141683 (-0.028643) | 1.450750 / 1.452155 (-0.001405) | 1.490265 / 1.492716 (-0.002452) |

### 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.252860 / 0.018006 (0.234854) | 0.554299 / 0.000490 (0.553810) | 0.002105 / 0.000200 (0.001905) | 0.000091 / 0.000054 (0.000037) |

### Benchmark: benchmark_indices_mapping.json

| metric | select | shard | shuffle | sort | train_test_split |
|--------|---|---|---|---|---|
| new / old (diff) | 0.026557 / 0.037411 (-0.010854) | 0.104464 / 0.014526 (0.089938) | 0.116724 / 0.176557 (-0.059833) | 0.154736 / 0.737135 (-0.582399) | 0.122017 / 0.296338 (-0.174322) |

### 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.398170 / 0.215209 (0.182961) | 3.979309 / 2.077655 (1.901654) | 1.773051 / 1.504120 (0.268931) | 1.587247 / 1.541195 (0.046053) | 1.620446 / 1.468490 (0.151956) | 0.692152 / 4.584777 (-3.892625) | 3.724821 / 3.745712 (-0.020891) | 2.133122 / 5.269862 (-3.136739) | 1.455612 / 4.565676 (-3.110065) | 0.084721 / 0.424275 (-0.339554) | 0.012461 / 0.007607 (0.004854) | 0.498909 / 0.226044 (0.272865) | 4.983837 / 2.268929 (2.714908) | 2.258489 / 55.444624 (-53.186135) | 1.891690 / 6.876477 (-4.984786) | 1.976944 / 2.142072 (-0.165128) | 0.836950 / 4.805227 (-3.968277) | 0.165401 / 6.500664 (-6.335263) | 0.061623 / 0.075469 (-0.013846) |

### 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.205945 / 1.841788 (-0.635842) | 15.101603 / 8.074308 (7.027295) | 14.393739 / 10.191392 (4.202347) | 0.176313 / 0.680424 (-0.504110) | 0.029102 / 0.534201 (-0.505099) | 0.439785 / 0.579283 (-0.139498) | 0.437360 / 0.434364 (0.002996) | 0.539668 / 0.540337 (-0.000669) | 0.641452 / 1.386936 (-0.745484) |

PyArrow==latest

Show updated benchmarks!

### 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.007184 / 0.011353 (-0.004169) | 0.005215 / 0.011008 (-0.005793) | 0.074617 / 0.038508 (0.036109) | 0.033209 / 0.023109 (0.010100) | 0.334304 / 0.275898 (0.058406) | 0.370270 / 0.323480 (0.046790) | 0.005851 / 0.007986 (-0.002135) | 0.004106 / 0.004328 (-0.000222) | 0.075487 / 0.004250 (0.071237) | 0.051133 / 0.037052 (0.014080) | 0.335401 / 0.258489 (0.076912) | 0.391457 / 0.293841 (0.097616) | 0.036525 / 0.128546 (-0.092021) | 0.012423 / 0.075646 (-0.063223) | 0.086446 / 0.419271 (-0.332825) | 0.050707 / 0.043533 (0.007174) | 0.336186 / 0.255139 (0.081047) | 0.353273 / 0.283200 (0.070074) | 0.105625 / 0.141683 (-0.036057) | 1.486118 / 1.452155 (0.033963) | 1.584931 / 1.492716 (0.092214) |

### 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.237589 / 0.018006 (0.219583) | 0.552030 / 0.000490 (0.551540) | 0.002863 / 0.000200 (0.002663) | 0.000097 / 0.000054 (0.000042) |

### Benchmark: benchmark_indices_mapping.json

| metric | select | shard | shuffle | sort | train_test_split |
|--------|---|---|---|---|---|
| new / old (diff) | 0.028078 / 0.037411 (-0.009333) | 0.112516 / 0.014526 (0.097990) | 0.121119 / 0.176557 (-0.055438) | 0.158874 / 0.737135 (-0.578262) | 0.129501 / 0.296338 (-0.166837) |

### 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.419479 / 0.215209 (0.204270) | 4.192216 / 2.077655 (2.114561) | 1.990513 / 1.504120 (0.486393) | 1.792892 / 1.541195 (0.251697) | 1.853904 / 1.468490 (0.385413) | 0.712702 / 4.584777 (-3.872074) | 3.820682 / 3.745712 (0.074970) | 2.143695 / 5.269862 (-3.126166) | 1.369621 / 4.565676 (-3.196055) | 0.087451 / 0.424275 (-0.336824) | 0.012622 / 0.007607 (0.005014) | 0.521056 / 0.226044 (0.295011) | 5.204873 / 2.268929 (2.935944) | 2.481169 / 55.444624 (-52.963455) | 2.112134 / 6.876477 (-4.764342) | 2.200681 / 2.142072 (0.058609) | 0.860323 / 4.805227 (-3.944904) | 0.171452 / 6.500664 (-6.329212) | 0.065235 / 0.075469 (-0.010234) |

### 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.241047 / 1.841788 (-0.600741) | 14.977890 / 8.074308 (6.903582) | 13.584265 / 10.191392 (3.392873) | 0.180050 / 0.680424 (-0.500374) | 0.018247 / 0.534201 (-0.515954) | 0.429585 / 0.579283 (-0.149698) | 0.429448 / 0.434364 (-0.004916) | 0.542663 / 0.540337 (0.002326) | 0.649525 / 1.386936 (-0.737411) |

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

Show benchmarks

PyArrow==6.0.0

Show updated benchmarks!

### 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.011289 / 0.011353 (-0.000064) | 0.005841 / 0.011008 (-0.005167) | 0.120994 / 0.038508 (0.082486) | 0.043627 / 0.023109 (0.020517) | 0.353254 / 0.275898 (0.077356) | 0.394685 / 0.323480 (0.071205) | 0.009520 / 0.007986 (0.001535) | 0.004770 / 0.004328 (0.000442) | 0.088857 / 0.004250 (0.084607) | 0.048426 / 0.037052 (0.011373) | 0.353815 / 0.258489 (0.095326) | 0.404109 / 0.293841 (0.110268) | 0.060079 / 0.128546 (-0.068467) | 0.013840 / 0.075646 (-0.061806) | 0.403133 / 0.419271 (-0.016139) | 0.072227 / 0.043533 (0.028694) | 0.354585 / 0.255139 (0.099446) | 0.377937 / 0.283200 (0.094737) | 0.139080 / 0.141683 (-0.002602) | 1.733266 / 1.452155 (0.281112) | 1.828402 / 1.492716 (0.335686) |

### 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.215095 / 0.018006 (0.197088) | 0.486669 / 0.000490 (0.486179) | 0.001425 / 0.000200 (0.001225) | 0.000097 / 0.000054 (0.000043) |

### Benchmark: benchmark_indices_mapping.json

| metric | select | shard | shuffle | sort | train_test_split |
|--------|---|---|---|---|---|
| new / old (diff) | 0.032832 / 0.037411 (-0.004579) | 0.136335 / 0.014526 (0.121809) | 0.141827 / 0.176557 (-0.034730) | 0.185917 / 0.737135 (-0.551218) | 0.149046 / 0.296338 (-0.147293) |

### 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.474587 / 0.215209 (0.259378) | 4.753686 / 2.077655 (2.676031) | 2.152147 / 1.504120 (0.648027) | 1.941762 / 1.541195 (0.400567) | 2.077493 / 1.468490 (0.609003) | 0.822432 / 4.584777 (-3.762345) | 4.860151 / 3.745712 (1.114439) | 2.527292 / 5.269862 (-2.742569) | 1.580442 / 4.565676 (-2.985234) | 0.102104 / 0.424275 (-0.322171) | 0.015060 / 0.007607 (0.007453) | 0.598780 / 0.226044 (0.372736) | 5.998318 / 2.268929 (3.729390) | 2.754115 / 55.444624 (-52.690509) | 2.317509 / 6.876477 (-4.558967) | 2.409942 / 2.142072 (0.267870) | 1.008830 / 4.805227 (-3.796397) | 0.196203 / 6.500664 (-6.304461) | 0.075378 / 0.075469 (-0.000091) |

### 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.430676 / 1.841788 (-0.411112) | 19.597628 / 8.074308 (11.523320) | 17.364673 / 10.191392 (7.173281) | 0.216621 / 0.680424 (-0.463803) | 0.039505 / 0.534201 (-0.494696) | 0.529027 / 0.579283 (-0.050256) | 0.572014 / 0.434364 (0.137650) | 0.702898 / 0.540337 (0.162560) | 0.785748 / 1.386936 (-0.601188) |

PyArrow==latest

Show updated benchmarks!

### 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.009150 / 0.011353 (-0.002203) | 0.006088 / 0.011008 (-0.004920) | 0.090629 / 0.038508 (0.052121) | 0.044284 / 0.023109 (0.021174) | 0.411363 / 0.275898 (0.135465) | 0.445499 / 0.323480 (0.122020) | 0.007129 / 0.007986 (-0.000856) | 0.004843 / 0.004328 (0.000515) | 0.087919 / 0.004250 (0.083668) | 0.060329 / 0.037052 (0.023277) | 0.405802 / 0.258489 (0.147313) | 0.468301 / 0.293841 (0.174460) | 0.044271 / 0.128546 (-0.084275) | 0.014895 / 0.075646 (-0.060751) | 0.103728 / 0.419271 (-0.315544) | 0.084190 / 0.043533 (0.040657) | 0.407210 / 0.255139 (0.152071) | 0.432585 / 0.283200 (0.149386) | 0.137132 / 0.141683 (-0.004550) | 1.720261 / 1.452155 (0.268107) | 1.858575 / 1.492716 (0.365858) |

### 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.331395 / 0.018006 (0.313389) | 0.494757 / 0.000490 (0.494267) | 0.043426 / 0.000200 (0.043226) | 0.000470 / 0.000054 (0.000415) |

### Benchmark: benchmark_indices_mapping.json

| metric | select | shard | shuffle | sort | train_test_split |
|--------|---|---|---|---|---|
| new / old (diff) | 0.035288 / 0.037411 (-0.002123) | 0.140856 / 0.014526 (0.126330) | 0.146597 / 0.176557 (-0.029959) | 0.192775 / 0.737135 (-0.544360) | 0.155307 / 0.296338 (-0.141032) |

### 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.504000 / 0.215209 (0.288791) | 5.011081 / 2.077655 (2.933427) | 2.380420 / 1.504120 (0.876300) | 2.154819 / 1.541195 (0.613624) | 2.293883 / 1.468490 (0.825393) | 0.864429 / 4.584777 (-3.720348) | 5.134475 / 3.745712 (1.388763) | 4.984024 / 5.269862 (-0.285837) | 2.333754 / 4.565676 (-2.231923) | 0.105854 / 0.424275 (-0.318422) | 0.015833 / 0.007607 (0.008226) | 0.633614 / 0.226044 (0.407569) | 6.330974 / 2.268929 (4.062046) | 3.020498 / 55.444624 (-52.424126) | 2.578234 / 6.876477 (-4.298243) | 2.654429 / 2.142072 (0.512357) | 1.022041 / 4.805227 (-3.783186) | 0.205085 / 6.500664 (-6.295579) | 0.081122 / 0.075469 (0.005653) |

### 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.538929 / 1.841788 (-0.302859) | 19.907799 / 8.074308 (11.833490) | 17.174568 / 10.191392 (6.983176) | 0.228165 / 0.680424 (-0.452258) | 0.024688 / 0.534201 (-0.509513) | 0.508958 / 0.579283 (-0.070326) | 0.544469 / 0.434364 (0.110105) | 0.590805 / 0.540337 (0.050468) | 0.705947 / 1.386936 (-0.680989) |

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

Show benchmarks

PyArrow==6.0.0

Show updated benchmarks!

### 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.008377 / 0.011353 (-0.002975) | 0.004445 / 0.011008 (-0.006563) | 0.100671 / 0.038508 (0.062163) | 0.029216 / 0.023109 (0.006107) | 0.300311 / 0.275898 (0.024413) | 0.356907 / 0.323480 (0.033427) | 0.006921 / 0.007986 (-0.001065) | 0.003384 / 0.004328 (-0.000944) | 0.078529 / 0.004250 (0.074278) | 0.034689 / 0.037052 (-0.002364) | 0.304647 / 0.258489 (0.046158) | 0.343584 / 0.293841 (0.049743) | 0.032700 / 0.128546 (-0.095846) | 0.011403 / 0.075646 (-0.064244) | 0.321540 / 0.419271 (-0.097732) | 0.040770 / 0.043533 (-0.002762) | 0.306900 / 0.255139 (0.051761) | 0.322482 / 0.283200 (0.039282) | 0.085396 / 0.141683 (-0.056287) | 1.450735 / 1.452155 (-0.001419) | 1.491829 / 1.492716 (-0.000888) |

### 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.009439 / 0.018006 (-0.008567) | 0.406805 / 0.000490 (0.406315) | 0.002993 / 0.000200 (0.002793) | 0.000102 / 0.000054 (0.000048) |

### Benchmark: benchmark_indices_mapping.json

| metric | select | shard | shuffle | sort | train_test_split |
|--------|---|---|---|---|---|
| new / old (diff) | 0.025034 / 0.037411 (-0.012378) | 0.100567 / 0.014526 (0.086042) | 0.107267 / 0.176557 (-0.069290) | 0.149945 / 0.737135 (-0.587190) | 0.111150 / 0.296338 (-0.185189) |

### 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.418387 / 0.215209 (0.203178) | 4.177979 / 2.077655 (2.100324) | 1.886650 / 1.504120 (0.382530) | 1.685692 / 1.541195 (0.144497) | 1.728270 / 1.468490 (0.259780) | 0.700904 / 4.584777 (-3.883873) | 3.379998 / 3.745712 (-0.365714) | 1.874779 / 5.269862 (-3.395083) | 1.170366 / 4.565676 (-3.395310) | 0.083190 / 0.424275 (-0.341085) | 0.012506 / 0.007607 (0.004899) | 0.528633 / 0.226044 (0.302589) | 5.301793 / 2.268929 (3.032865) | 2.334050 / 55.444624 (-53.110574) | 1.986988 / 6.876477 (-4.889488) | 2.020508 / 2.142072 (-0.121565) | 0.817227 / 4.805227 (-3.988000) | 0.150284 / 6.500664 (-6.350380) | 0.065489 / 0.075469 (-0.009980) |

### 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.224216 / 1.841788 (-0.617572) | 13.729808 / 8.074308 (5.655500) | 14.283402 / 10.191392 (4.092010) | 0.159434 / 0.680424 (-0.520990) | 0.028471 / 0.534201 (-0.505730) | 0.395102 / 0.579283 (-0.184181) | 0.402733 / 0.434364 (-0.031631) | 0.470852 / 0.540337 (-0.069485) | 0.568530 / 1.386936 (-0.818406) |

PyArrow==latest

Show updated benchmarks!

### 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.006750 / 0.011353 (-0.004603) | 0.004479 / 0.011008 (-0.006529) | 0.074926 / 0.038508 (0.036418) | 0.027619 / 0.023109 (0.004510) | 0.342070 / 0.275898 (0.066172) | 0.372452 / 0.323480 (0.048972) | 0.005094 / 0.007986 (-0.002892) | 0.003494 / 0.004328 (-0.000834) | 0.074963 / 0.004250 (0.070713) | 0.038457 / 0.037052 (0.001405) | 0.340587 / 0.258489 (0.082098) | 0.381212 / 0.293841 (0.087371) | 0.031597 / 0.128546 (-0.096950) | 0.011631 / 0.075646 (-0.064015) | 0.084646 / 0.419271 (-0.334626) | 0.042072 / 0.043533 (-0.001461) | 0.340977 / 0.255139 (0.085838) | 0.366502 / 0.283200 (0.083302) | 0.091181 / 0.141683 (-0.050502) | 1.435119 / 1.452155 (-0.017035) | 1.520426 / 1.492716 (0.027710) |

### 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.211320 / 0.018006 (0.193313) | 0.466154 / 0.000490 (0.465664) | 0.002901 / 0.000200 (0.002701) | 0.000080 / 0.000054 (0.000026) |

### Benchmark: benchmark_indices_mapping.json

| metric | select | shard | shuffle | sort | train_test_split |
|--------|---|---|---|---|---|
| new / old (diff) | 0.025122 / 0.037411 (-0.012289) | 0.098929 / 0.014526 (0.084403) | 0.106551 / 0.176557 (-0.070005) | 0.142820 / 0.737135 (-0.594316) | 0.110701 / 0.296338 (-0.185637) |

### 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.445187 / 0.215209 (0.229978) | 4.457524 / 2.077655 (2.379870) | 2.088323 / 1.504120 (0.584203) | 1.888076 / 1.541195 (0.346881) | 1.923340 / 1.468490 (0.454850) | 0.723354 / 4.584777 (-3.861423) | 3.428479 / 3.745712 (-0.317233) | 1.914580 / 5.269862 (-3.355281) | 1.191810 / 4.565676 (-3.373866) | 0.087008 / 0.424275 (-0.337267) | 0.013431 / 0.007607 (0.005824) | 0.545089 / 0.226044 (0.319044) | 5.465887 / 2.268929 (3.196958) | 2.527431 / 55.444624 (-52.917194) | 2.240622 / 6.876477 (-4.635854) | 2.232472 / 2.142072 (0.090399) | 0.815968 / 4.805227 (-3.989259) | 0.152842 / 6.500664 (-6.347822) | 0.067152 / 0.075469 (-0.008317) |

### 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.328360 / 1.841788 (-0.513427) | 14.163349 / 8.074308 (6.089040) | 13.814255 / 10.191392 (3.622863) | 0.131684 / 0.680424 (-0.548740) | 0.016980 / 0.534201 (-0.517221) | 0.396045 / 0.579283 (-0.183238) | 0.395078 / 0.434364 (-0.039286) | 0.471728 / 0.540337 (-0.068609) | 0.567830 / 1.386936 (-0.819106) |

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

Show benchmarks

PyArrow==6.0.0

Show updated benchmarks!

### 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.012630 / 0.011353 (0.001277) | 0.007038 / 0.011008 (-0.003970) | 0.158816 / 0.038508 (0.120308) | 0.044142 / 0.023109 (0.021032) | 0.389393 / 0.275898 (0.113495) | 0.479745 / 0.323480 (0.156265) | 0.009335 / 0.007986 (0.001349) | 0.005434 / 0.004328 (0.001105) | 0.107747 / 0.004250 (0.103497) | 0.048382 / 0.037052 (0.011330) | 0.398144 / 0.258489 (0.139655) | 0.446373 / 0.293841 (0.152532) | 0.066285 / 0.128546 (-0.062261) | 0.021174 / 0.075646 (-0.054472) | 0.449176 / 0.419271 (0.029905) | 0.063044 / 0.043533 (0.019511) | 0.390523 / 0.255139 (0.135384) | 0.451435 / 0.283200 (0.168236) | 0.116369 / 0.141683 (-0.025314) | 1.881269 / 1.452155 (0.429114) | 1.944527 / 1.492716 (0.451811) |

### 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.227989 / 0.018006 (0.209983) | 0.538514 / 0.000490 (0.538024) | 0.009404 / 0.000200 (0.009204) | 0.000510 / 0.000054 (0.000455) |

### Benchmark: benchmark_indices_mapping.json

| metric | select | shard | shuffle | sort | train_test_split |
|--------|---|---|---|---|---|
| new / old (diff) | 0.029826 / 0.037411 (-0.007585) | 0.129623 / 0.014526 (0.115098) | 0.142067 / 0.176557 (-0.034489) | 0.218586 / 0.737135 (-0.518549) | 0.160524 / 0.296338 (-0.135814) |

### 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.667195 / 0.215209 (0.451986) | 6.694192 / 2.077655 (4.616537) | 2.542493 / 1.504120 (1.038373) | 2.124042 / 1.541195 (0.582847) | 2.024854 / 1.468490 (0.556364) | 1.306222 / 4.584777 (-3.278555) | 5.631557 / 3.745712 (1.885845) | 3.405978 / 5.269862 (-1.863884) | 2.471399 / 4.565676 (-2.094278) | 0.165187 / 0.424275 (-0.259088) | 0.014880 / 0.007607 (0.007273) | 0.842718 / 0.226044 (0.616673) | 8.584358 / 2.268929 (6.315430) | 3.377228 / 55.444624 (-52.067396) | 2.667265 / 6.876477 (-4.209212) | 2.699462 / 2.142072 (0.557389) | 1.623115 / 4.805227 (-3.182112) | 0.253929 / 6.500664 (-6.246735) | 0.077189 / 0.075469 (0.001720) |

### 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.778962 / 1.841788 (-0.062825) | 18.997636 / 8.074308 (10.923328) | 24.255222 / 10.191392 (14.063830) | 0.304754 / 0.680424 (-0.375670) | 0.049656 / 0.534201 (-0.484545) | 0.590871 / 0.579283 (0.011588) | 0.649292 / 0.434364 (0.214928) | 0.751281 / 0.540337 (0.210943) | 0.872193 / 1.386936 (-0.514743) |

PyArrow==latest

Show updated benchmarks!

### 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.010660 / 0.011353 (-0.000693) | 0.006492 / 0.011008 (-0.004516) | 0.112190 / 0.038508 (0.073682) | 0.045391 / 0.023109 (0.022281) | 0.439852 / 0.275898 (0.163954) | 0.486489 / 0.323480 (0.163009) | 0.007155 / 0.007986 (-0.000830) | 0.006323 / 0.004328 (0.001995) | 0.099775 / 0.004250 (0.095525) | 0.055762 / 0.037052 (0.018709) | 0.439457 / 0.258489 (0.180968) | 0.505322 / 0.293841 (0.211481) | 0.057019 / 0.128546 (-0.071527) | 0.031382 / 0.075646 (-0.044264) | 0.121211 / 0.419271 (-0.298061) | 0.066091 / 0.043533 (0.022558) | 0.499760 / 0.255139 (0.244622) | 0.508312 / 0.283200 (0.225113) | 0.146975 / 0.141683 (0.005292) | 1.916347 / 1.452155 (0.464193) | 2.065860 / 1.492716 (0.573144) |

### 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.247176 / 0.018006 (0.229170) | 0.565141 / 0.000490 (0.564652) | 0.004841 / 0.000200 (0.004641) | 0.000141 / 0.000054 (0.000087) |

### Benchmark: benchmark_indices_mapping.json

| metric | select | shard | shuffle | sort | train_test_split |
|--------|---|---|---|---|---|
| new / old (diff) | 0.036378 / 0.037411 (-0.001033) | 0.143470 / 0.014526 (0.128944) | 0.148096 / 0.176557 (-0.028461) | 0.225877 / 0.737135 (-0.511258) | 0.147072 / 0.296338 (-0.149266) |

### 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.723119 / 0.215209 (0.507910) | 6.824981 / 2.077655 (4.747326) | 2.883840 / 1.504120 (1.379720) | 2.468707 / 1.541195 (0.927513) | 2.525549 / 1.468490 (1.057059) | 1.426640 / 4.584777 (-3.158137) | 5.816045 / 3.745712 (2.070333) | 5.727037 / 5.269862 (0.457175) | 2.650307 / 4.565676 (-1.915369) | 0.160306 / 0.424275 (-0.263970) | 0.015371 / 0.007607 (0.007764) | 0.835778 / 0.226044 (0.609733) | 8.622836 / 2.268929 (6.353907) | 3.616338 / 55.444624 (-51.828287) | 2.974243 / 6.876477 (-3.902234) | 2.884557 / 2.142072 (0.742485) | 1.734874 / 4.805227 (-3.070353) | 0.277474 / 6.500664 (-6.223190) | 0.094189 / 0.075469 (0.018720) |

### 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.785728 / 1.841788 (-0.056059) | 19.376490 / 8.074308 (11.302182) | 24.560403 / 10.191392 (14.369011) | 0.250686 / 0.680424 (-0.429738) | 0.034333 / 0.534201 (-0.499868) | 0.557331 / 0.579283 (-0.021952) | 0.641007 / 0.434364 (0.206643) | 0.657138 / 0.540337 (0.116800) | 0.759023 / 1.386936 (-0.627913) |

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

I am editing the title and description of this PR:
- It should be "Lint code" instead of "Format code": formatting was still done with `black`
- This PR uses `ruff` instead of `isort` and `flake8` (not `black`): note that `black` was still used for formatting

EDIT:
Use `ruff` for linting instead of `isort` and `flake8` ~~`black`~~ to be consistent with [`transformers`](https://github.com/huggingface/transformers/pull/21480) and [`hfh`](https://github.com/huggingface/huggingface_hub/pull/1323).

TODO:
- [x] ~Merge the community contributors' PR to avoid having to run `make style` on their PR branches~ (we have some new PRs, but fixing those shouldn't be too big of a problem)