MCPcopy Create free account
hub / github.com/apache/tvm-ffi / _maybe_write

Function _maybe_write

python/tvm_ffi/cpp/extension.py:123–132  ·  view source on GitHub ↗

Write content to path if it does not already exist with the same content.

(path: str, content: str)

Source from the content-addressed store, hash-verified

121
122
123def _maybe_write(path: str, content: str) -> None:
124 """Write content to path if it does not already exist with the same content."""
125 p = Path(path)
126 if p.exists():
127 with p.open() as f:
128 existing_content = f.read()
129 if existing_content == content:
130 return
131 with p.open("w") as f:
132 f.write(content)
133
134
135@functools.lru_cache

Callers 2

_build_implFunction · 0.85
build_inlineFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected