from Hacker News

Tree – a lib for working with nested data structures, open-sourced by deepmind

by okokok___ on 1/23/21, 10:19 PM with 14 comments

  • by thundergolfer on 1/24/21, 1:04 AM

    For those using Bazel this looks like a pretty helpful example of developing and releasing a cross-platform Python package with native-libs (C++ in this case).

    I've wondered for a while how Deepmind manages their (Python & C++) codebase. This is a small window into that I think, and you can see that they're likely using internal 'Blaze' Python rules and rely on the maintenance of compatibility with the open-source Bazel rules. `py_library` is used in `tree/BUILD`, but it is not loaded explicitly as is expected with Bazel these days; the rule definition is loaded by Bazel implicitly.

  • by jimfleming on 1/24/21, 3:35 AM

    From the tree docs:

    > tree has originally been part of TensorFlow and is available as tf.nest.

    The tf.nest docs can be found here and may be more useful for now: https://www.tensorflow.org/api_docs/python/tf/nest

    I'm glad this is being moved out of TensorFlow. It's a really useful library on its own and I've found myself reaching for it on projects without wanting to import all of TensorFlow.

  • by fulafel on 1/24/21, 10:51 AM

    Caveat emptor: "The behavior for structures with cycle references is undefined"

    Isn't this a pretty common error to occur in Python programs? It would be good to at least have a checked mode available, otherwise the "dragons may fly out of your nose" semantics feels like a pretty aggressive compromise in favour of performance vs correctness.

  • by asimjalis on 1/23/21, 11:59 PM

    Nice. Although I wish the documentation was less sparse.
  • by slightwinder on 1/25/21, 10:22 AM

    So all it's doing is flatten the tree?