假设允许两种不同的方式来定义派生策略,@composite
并且flatmap
。据我所知,前者可以做后者可以做的任何事情。但是,numpy策略的实施arrays
,讲了一些隐性成本
# 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
时候应该像上面链接的实现那样走这条中途路线?