Another sneaky one is the `is` operator in Python, where the Python documentation says:
> Due to automatic garbage-collection, free lists, and the dynamic nature of descriptors, you may notice seemingly unusual behaviour in certain uses of the `is` operator
Related to that is the `__del__` method: when exactly is it called?
It's quite easy to get non-deterministic code in Python and in many languages. And of course, there are lots of non-deterministic functions in the standard library (Starlark doesn't provide them).
Yeah, also Starlark is embedded like Lua, and doesn't come with batteries included like Python
So that means you can control the APIs, and say opendir() closedir() in Unix returns filenames in different orders. Depending on what the data structure in the kernel is
So many programs in other languages aren't deterministic just because they use APIs that aren't deterministic
It can be very valuable to know that if you put the same files in, you get _exactly_ byte-for-byte identical artifacts out of your build system. Even letting your language access the actual current date/time can break that.
(IIRC, I don't believe Bazel actually has fully deterministic builds yet, though.)
laurentlb|1 year ago
id("ab") # not deterministic
hash("ab") # not deterministic
def foo(): pass
str(foo) # not deterministic
Another sneaky one is the `is` operator in Python, where the Python documentation says:
> Due to automatic garbage-collection, free lists, and the dynamic nature of descriptors, you may notice seemingly unusual behaviour in certain uses of the `is` operator
Related to that is the `__del__` method: when exactly is it called?
It's quite easy to get non-deterministic code in Python and in many languages. And of course, there are lots of non-deterministic functions in the standard library (Starlark doesn't provide them).
phyrex|1 year ago
lann|1 year ago
chubot|1 year ago
So that means you can control the APIs, and say opendir() closedir() in Unix returns filenames in different orders. Depending on what the data structure in the kernel is
So many programs in other languages aren't deterministic just because they use APIs that aren't deterministic
zellyn|1 year ago
(IIRC, I don't believe Bazel actually has fully deterministic builds yet, though.)
neuroelectron|1 year ago