Proposal: Use a single seed value per faker function invocation #2664
Labels
c: feature
Request for new feature
p: 1-normal
Nothing urgent
s: accepted
Accepted feature / Confirmed bug
s: on hold
Blocked by something or frozen to avoid conflicts
Milestone
Clear and concise description of the problem
Glossary:
Currently when invoking a faker function it may consume an unknown number of seed values (0-n).
While that isn't bad by itself, it has the side effect, that any change to the implementation affects the user by generating different subsequent values. This is especially relevant for functions that generate multiple values such as multiple and unique, each of the generated elements affect the following elements generated in them and all elements afterwards.
Suggested solution
Let each method use only a single seed value by deriving it, if it uses more than one.
Each method would be responsible for itself to consume only a single seed value.
Important usage detail, the
fakerCore
instance must be passed on and used by any nested code.Deriving an instance does come at a performance cost, but we could make it cheap, if we keep that as a priority during the derive implementation and use standalone functions like teased in the code example.
E.g. by not re-initializing the twister from scratch, but only copy and transforming the state.
(We should measure though how much "re-initializing" vs "copy and transforming the state" actually has of a performance impact)
It also comes at a cost of additional code, we could hide that in our potential meta framework though.
This section is largely unrelated to this proposal and should just demonstrate, how the derive could be included in the potential meta framework.
Usage
Alternative
Don't change the current behavior.
Additional context
Relevant issues/PRs:
Potentially impacted issues/PRs:
We already talked about this feature quite a bit, but I would like to have this issue, to bring everybody on the same level.
And give everybody the chance to comment and react.
The text was updated successfully, but these errors were encountered: