2 ms·
I've found the faker library [1] useful. The fake data that I've bothered to model are weighted age ranges. Fortunately, as of Python3.6, you can access it fr
by Dowwie 9y ago
I've found the faker library [1] useful.
The fake data that I've bothered to model are weighted age ranges. Fortunately, as of Python3.6, you can access it from random.choices [2] in the stdlib
[1] https://github.com/joke2k/faker https://github.com/joke2k/faker
[2] https://docs.python.org/3/library/random.html#random.choices https://docs.python.org/3/library/random.html#random.choices
example: https://gist.github.com/Dowwie/8409d871ddae913e44c61bc4d47ce1cc https://gist.github.com/Dowwie/8409d871ddae913e44c61bc4d47ce...
- logv 9y agopart of what prompted the work on plait.py was that joke2k/faker was reasonably slow to generate 10K fake names for me: https://paste.ubuntu.com/26354987/ https://paste.ubuntu.com/26354987/ PS. that's a really cool python tip!
- Dowwie 9y agoWell done, then! :) Is plait a drop-in replacement for faker?
- logv 9y agoit's a drop in replacement for stympy/faker, but not joke2k faker joke2k/faker is python and the data is stored in code (all or most of the random values are in .py files around the codebase), perhaps leading to its slowness. stympy/faker is ruby and its random values are in yaml files, with some fields defined as ruby functions (those are not supported by plait.py). can use 'plait -l' and 'plait -ll name' and 'plait -ll name.name' (more info in the README) to get a list of fake fields available.
- Dowwie 9y agoif/when you tire with the latest performance improvement, consider porting to Rust and adapting it to python via cffi