【发布时间】:2020-04-08 02:29:33
【问题描述】:
假设允许两种不同的方式来定义派生策略,@composite 和 flatmap。据我所知,前者可以做后者可以做的任何事情。但是,numpy arrays 策略的 implementation 谈到了一些隐藏成本
# We support passing strategies as arguments for convenience, or at least
# for legacy reasons, but don't want to pay the perf cost of a composite
# strategy (i.e. repeated argument handling and validation) when it's not
# needed. So we get the best of both worlds by recursing with flatmap,
# but only when it's actually needed.
我认为这意味着更严重的收缩行为,但我不确定,我无法在其他任何地方找到此文档。那么我应该什么时候使用@composite,什么时候使用flatmap,什么时候应该像上面链接的实现那样走这条中途路线?
【问题讨论】:
标签: python property-based-testing python-hypothesis