{"action":"created","issue":{"url":"https://api.github.com/repos/google/flatbuffers/issues/281","labels_url":"https://api.github.com/repos/google/flatbuffers/issues/281/labels{/name}","comments_url":"https://api.github.com/repos/google/flatbuffers/issues/281/comments","events_url":"https://api.github.com/repos/google/flatbuffers/issues/281/events","html_url":"https://github.com/google/flatbuffers/issues/281","id":108388177,"number":281,"title":"Python: Add index field setter to generated code","user":{"login":"Downchuck","id":141466,"avatar_url":"https://avatars.githubusercontent.com/u/141466?v=3","gravatar_id":"","url":"https://api.github.com/users/Downchuck","html_url":"https://github.com/Downchuck","followers_url":"https://api.github.com/users/Downchuck/followers","following_url":"https://api.github.com/users/Downchuck/following{/other_user}","gists_url":"https://api.github.com/users/Downchuck/gists{/gist_id}","starred_url":"https://api.github.com/users/Downchuck/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Downchuck/subscriptions","organizations_url":"https://api.github.com/users/Downchuck/orgs","repos_url":"https://api.github.com/users/Downchuck/repos","events_url":"https://api.github.com/users/Downchuck/events{/privacy}","received_events_url":"https://api.github.com/users/Downchuck/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-09-25T18:59:55Z","updated_at":"2015-09-25T19:30:35Z","closed_at":null,"body":"I'm working on transforming data into flatbuffers, and it'd be far easier and more efficient for me to be able to add to a buffer via index instead of name.\r\n\r\nThis would involve generating a new method for python code gen:\r\n```\r\nidl_gen_python.cpp\r\n```\r\n\r\nSo while we have methods like this:\r\n```\r\ndef namesAddTb(builder, Tb): builder.PrependInt64Slot(0, Tb, 0)\r\ndef namesAddNb(builder, Np): builder.PrependInt32Slot(1, Np, 0)\r\n```\r\n\r\nI would add an Addbyindex method:\r\n```\r\ndef namesAddbyindex(builder, idx, datum):\r\n   if idx == 0: builder.PrependInt64Slot(0, datum, 0)\r\n   else if idx == 1: builder.PrependInt32Slot(1, datum, 0)\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/google/flatbuffers/issues/comments/143331898","html_url":"https://github.com/google/flatbuffers/issues/281#issuecomment-143331898","issue_url":"https://api.github.com/repos/google/flatbuffers/issues/281","id":143331898,"user":{"login":"Downchuck","id":141466,"avatar_url":"https://avatars.githubusercontent.com/u/141466?v=3","gravatar_id":"","url":"https://api.github.com/users/Downchuck","html_url":"https://github.com/Downchuck","followers_url":"https://api.github.com/users/Downchuck/followers","following_url":"https://api.github.com/users/Downchuck/following{/other_user}","gists_url":"https://api.github.com/users/Downchuck/gists{/gist_id}","starred_url":"https://api.github.com/users/Downchuck/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Downchuck/subscriptions","organizations_url":"https://api.github.com/users/Downchuck/orgs","repos_url":"https://api.github.com/users/Downchuck/repos","events_url":"https://api.github.com/users/Downchuck/events{/privacy}","received_events_url":"https://api.github.com/users/Downchuck/received_events","type":"User","site_admin":false},"created_at":"2015-09-25T19:30:35Z","updated_at":"2015-09-25T19:30:35Z","body":"I am working with large batches of data, and manually typing out each add\ncommand with the key name is really time consuming, verbose and practically\nunnecessary given that code gen can handle it.\n\nIn this particular case I am processing messages in protobuf and\ntranslating them to flatbuf. That said, this technique is the same for\ntransforming across most serialization formats.\n\n-Charles\n\nOn Friday, September 25, 2015, Wouter van Oortmerssen <\nnotifications@github.com> wrote:\n\n> That sounds really specialized functionality, can you explain when this is\n> useful, and how others might need this too?\n>\n> —\n> Reply to this email directly or view it on GitHub\n> <https://github.com/google/flatbuffers/issues/281#issuecomment-143325175>.\n>\n"}}