{"action":"opened","issue":{"url":"https://api.github.com/repos/KeepSafe/aiohttp/issues/686","labels_url":"https://api.github.com/repos/KeepSafe/aiohttp/issues/686/labels{/name}","comments_url":"https://api.github.com/repos/KeepSafe/aiohttp/issues/686/comments","events_url":"https://api.github.com/repos/KeepSafe/aiohttp/issues/686/events","html_url":"https://github.com/KeepSafe/aiohttp/issues/686","id":122693887,"number":686,"title":"Fast xoring in python","user":{"login":"socketpair","id":1157412,"avatar_url":"https://avatars.githubusercontent.com/u/1157412?v=3","gravatar_id":"","url":"https://api.github.com/users/socketpair","html_url":"https://github.com/socketpair","followers_url":"https://api.github.com/users/socketpair/followers","following_url":"https://api.github.com/users/socketpair/following{/other_user}","gists_url":"https://api.github.com/users/socketpair/gists{/gist_id}","starred_url":"https://api.github.com/users/socketpair/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/socketpair/subscriptions","organizations_url":"https://api.github.com/users/socketpair/orgs","repos_url":"https://api.github.com/users/socketpair/repos","events_url":"https://api.github.com/users/socketpair/events{/privacy}","received_events_url":"https://api.github.com/users/socketpair/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-12-17T09:23:27Z","updated_at":"2015-12-17T09:23:27Z","closed_at":null,"body":"instead of \r\n\r\n```\r\ndef _websocket_mask_python(mask, data):\r\n    return bytes(b ^ mask[i % 4] for i, b in enumerate(data))\r\n```\r\n\r\nplease use this:\r\n\r\n```\r\native_byteorder = sys.byteorder\r\n\r\ndef _websocket_mask_python(mask, data):\r\n    assert len(mask) == 4\r\n    datalen = len(data)\r\n    if datalen == 0:\r\n        return b''  #  everything work without this, but may be changed later in python.\r\n    src = int.from_bytes(data, native_byteorder)\r\n    mask = int.from_bytes(mask * (datalen // 4) + mask[: datalen % 4], native_byteorder)\r\n    res = (src ^ mask)\r\n    return res.to_bytes(datalen, native_byteorder)\r\n```"}}