This is an automated email from the ASF dual-hosted git repository. mergebot-role pushed a commit to branch mergebot in repository https://gitbox.apache.org/repos/asf/beam-site.git
commit 1781b86778bed6fb9bfb72465128b8b09785c861 Author: Charles Chen <c...@google.com> AuthorDate: Mon Feb 5 16:28:03 2018 -0800 Clarify runtime type checking documentation --- src/documentation/sdks/python-type-safety.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/documentation/sdks/python-type-safety.md b/src/documentation/sdks/python-type-safety.md index ae8fc09..3962fe1 100644 --- a/src/documentation/sdks/python-type-safety.md +++ b/src/documentation/sdks/python-type-safety.md @@ -106,16 +106,18 @@ The following are special type hints that don't correspond to a class, but rathe In addition to using type hints for type checking at pipeline construction, you can enable runtime type checking to check that actual elements satisfy the declared type constraints during pipeline execution. -For example, the following code would pass at both pipeline construction and runtime. +For example, the following pipeline emits elements of the wrong type. Depending on the runner implementation, its execution may or may not fail at runtime. ``` {% github_sample /apache/beam/blob/master/sdks/python/apache_beam/examples/snippets/snippets_test.py tag:type_hints_runtime_off %}``` -However, if you enable runtime type checking, the code passes at pipeline construction and fails at runtime. To enable runtime type checking, set the pipeline option `runtime_type_check` to `True`. +However, if you enable runtime type checking, the code is guaranteed to fail at runtime. To enable runtime type checking, set the pipeline option `runtime_type_check` to `True`. ``` {% github_sample /apache/beam/blob/master/sdks/python/apache_beam/examples/snippets/snippets_test.py tag:type_hints_runtime_on %}``` +Note that because runtime type checks are done for each `PCollection` element, enabling this feature may incur a significant performance penalty. It is therefore recommended that runtime type checks are disabled for production pipelines. + ## Use of Type Hints in Coders When your pipeline reads, writes, or otherwise materializes its data, the elements in your `PCollection` need to be encoded and decoded to and from byte strings. Byte strings are used for intermediate storage, for comparing keys in `GroupByKey` operations, and for reading from sources and writing to sinks. -- To stop receiving notification emails like this one, please contact mergebot-r...@apache.org.