More efficient nested features encoding
{'login': 'eladsegal', 'id': 13485709, 'node_id': 'MDQ6VXNlcjEzNDg1NzA5', 'avatar_url': 'https://avatars.githubusercontent.com/u/13485709?v=4', 'gravatar_id': '', 'url': 'https://api.github.com/users/eladsegal', 'html_url': 'https://github.com/eladsegal', 'followers_url': 'https://api.github.com/users/eladsegal/followers', 'following_url': 'https://api.github.com/users/eladsegal/following{/other_user}', 'gists_url': 'https://api.github.com/users/eladsegal/gists{/gist_id}', 'starred_url': 'https://api.github.com/users/eladsegal/starred{/owner}{/repo}', 'subscriptions_url': 'https://api.github.com/users/eladsegal/subscriptions', 'organizations_url': 'https://api.github.com/users/eladsegal/orgs', 'repos_url': 'https://api.github.com/users/eladsegal/repos', 'events_url': 'https://api.github.com/users/eladsegal/events{/privacy}', 'received_events_url': 'https://api.github.com/users/eladsegal/received_events', 'type': 'User', 'site_admin': False}
[]
[]
@lhoestq @albertvillanova @mariosasko
Can you please check this out? Thanks, done!
Nested encoding of features wastes a lot of time on operations which are effectively doing nothing when lists are used.
For example, if in the input we have a list of integers, `encoded_nested_example` will iterate over it and apply `encoded_nested_example` on every element even though it just return the int as is.

A similar issue is handled at an earlier stage when casting pytorch/tensorflow/pandas objects to python lists/numpy arrays:
https://github.com/huggingface/datasets/blob/c98c23c4260edadab00f997d1a5d66b7f2e93ce9/src/datasets/features/features.py#L149-L156
https://github.com/huggingface/datasets/blob/c98c23c4260edadab00f997d1a5d66b7f2e93ce9/src/datasets/features/features.py#L212-L228

In this pull request I suggest to use the same approach in `encoded_nested_example`.
In my setup there was a major speedup with this change: loading the data was at least x4 faster. 
{'url': 'https://api.github.com/repos/huggingface/datasets/issues/3124/reactions', 'total_count': 0, '+1': 0, '-1': 0, 'laugh': 0, 'hooray': 0, 'confused': 0, 'heart': 0, 'rocket': 0, 'eyes': 0}
{'url': 'https://api.github.com/repos/huggingface/datasets/pulls/3124', 'html_url': 'https://github.com/huggingface/datasets/pull/3124', 'diff_url': 'https://github.com/huggingface/datasets/pull/3124.diff', 'patch_url': 'https://github.com/huggingface/datasets/pull/3124.patch', 'merged_at': '2021-11-02T11:04:04Z'}