)]}'
{
  "commit": "a3b9b949c5e29f42862cbc8fd26eb8062253b301",
  "tree": "f45ad49246119f769c39317557f7d13f8268f180",
  "parents": [
    "40505d88804e13754ae2cc97ba460ad98cd72e71"
  ],
  "author": {
    "name": "Mark Molinaro",
    "email": "mmolinaro@pinterest.com",
    "time": "Thu Apr 02 07:11:42 2026 +0000"
  },
  "committer": {
    "name": "Jens Geyer",
    "email": "Jens-G@users.noreply.github.com",
    "time": "Thu Apr 09 01:45:44 2026 +0200"
  },
  "message": "Optimize Python C extension readStruct for nested structs\n\nIn this area of code, there already exists an optimization where we skip calling `klass(**kwargs)` on the top-level struct and instead init an empty object then PyObject_SetAttr the properties onto it.\u2028\u2028This was done because Python\u0027s keyword\nargument matching is O(n) string comparisons per argument, making this expensive for structs with many fields.\n\nHowever, nested structs which are decoded within the C extension did not get this same optimization, causing them to go through the slow class initialization path.\n\nIn this change, for mutable nested structs, we create the instance up front with a no-arg constructor (klass()) and set decoded fields directly via PyObject_SetAttr (the same way we fast-path the top-level struct).\n\nImmutable structs (TFrozenBase subclasses) continue to use the kwargs\npath since their generated __setattr__ blocks attribute mutation.\n\nImmutability is detected via PyObject_IsSubclass against TFrozenBase,\nwith the class reference cached in a function-local static.\n\nBenchmarks show up to 3.6x speedup for deeply nested struct hierarchies, with no impact on flat structs. I had Claude generate me some benchmarks to showcase performance in different nested scenarios.\u2028\u2028Note the test change. I asked about potentially changing this to look more like what the codegen produces here https://github.com/apache/thrift/pull/3349/changes#r3026288637. Currently, this fails because its not marked as frozen but has a erroring setattr\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "b517c381eeb21c68dd1498eedb0bff419e029ddf",
      "old_mode": 33188,
      "old_path": "lib/py/src/ext/protocol.tcc",
      "new_id": "123ca69ea833eeeb2d253d6cfb6e253c4a73d4d3",
      "new_mode": 33188,
      "new_path": "lib/py/src/ext/protocol.tcc"
    }
  ]
}
