Conversation
da6d5e1 to
f216fbf
Compare
…ormat Replaces the full list of japanese postcodes in favor of a simple 7-digit format: "###-####". The reason is for performance, as generating a postcode in this locale is too expensive. Japanese postal codes were changed from a simple pattern to a list of real postal codes, introduced in #2297. The problem is that when running Faker on `locale = 'ja'`, about 60% of the time to load and call `Faker::Address.postalcode` is spent reading and parsing the [ja/address.yml](https://github.com/faker-ruby/faker/blob/main/lib/locales/ja/address.yml) file, which has 2.2mb. Benchmark: ``` Postcode - Smaller Address File: 1.2 i/s Postcode: 0.7 i/s - 1.65x slower 1.34 s/i vs 811.55 ms/i ``` This has the potential to improve the performance of generating postcodes in japanese by 65%.
f216fbf to
08f2ade
Compare
thdaraujo
commented
Jan 31, 2026
| assert_kind_of String, Faker::Subscription.status | ||
| assert_not_english(Faker::Subscription.status) | ||
| assert_kind_of String, Faker::Subscription.payment_method | ||
| assert Array.new(10) { Faker::Subscription.payment_method }.any? { |word| !word.match?(/[a-zA-Z]/) } |
Contributor
Author
There was a problem hiding this comment.
this test would randomly generate words that often wouldn't match the filter.
The weird thing is that it should have been happening on main too.
b2cf8df to
4dfe746
Compare
stefannibrasil
approved these changes
Jan 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

(fixes #3200)
This PR replaces the full list of postcodes with a 7-digit format for
ja/address.yml.The reason is for performance, as generating a postcode in this locale
is too expensive.
Japanese postal codes were changed from a simple pattern to a list of real postal codes, introduced in #2297.
The problem is that when running Faker on
locale = 'ja', about 60% of the time to load and callFaker::Address.postalcodeis spent reading and parsing the ja/address.yml file, which has 2.2mb.Benchmark:
This has the potential to improve the performance of generating
postcodes in japanese by 65%, as well as loading in general.
Gem size will also decrease by 200kb. 🎉
1.6M -> 1.4M