diff options
author | David Drysdale <drysdale@google.com> | 2021-01-04 14:13:16 +0000 |
---|---|---|
committer | David Drysdale <drysdale@google.com> | 2021-01-04 14:14:26 +0000 |
commit | 7ec7b3a38fd6ad58dce83e6e763f7027c9e92dd1 (patch) | |
tree | 5527ebc4c5c16888f433f605c1474736df52c180 | |
parent | 97cb808137f99a1c2611951f9ed3bb4db78222b5 (diff) |
README: clarify/correct metadata loading info
-rw-r--r-- | README.md | 36 |
1 files changed, 20 insertions, 16 deletions
@@ -181,33 +181,37 @@ For more information about the other functionality available from the library, l Memory Usage ------------ -The library includes a lot of metadata, giving a significant memory overhead. This metadata is loaded on-demand so that -the memory footprint of applications that only use a subset of the library functionality is not adversely affected. - -In particular: - -* The geocoding metadata (which is over 100 megabytes) is only loaded on the first use of - one of the geocoding functions (`geocoder.description_for_number`, `geocoder.description_for_valid_number` - or `geocoder.country_name_for_number`). -* The carrier metadata is only loaded on the first use of one of the mapping functions (`carrier.name_for_number` - or `carrier.name_for_valid_number`). -* The timezone metadata is only loaded on the first use of one of the timezone functions (`time_zones_for_number` - or `time_zones_for_geographical_number`). -* The normal metadata for each region is only loaded on the first time that metadata for that region is needed. +The library includes a lot of metadata, potentially giving a significant memory overhead. There are two mechanisms +for dealing with this. + +* The normal metadata for the core functionality of the library is loaded on-demand, on a region-by-region basis + (i.e. the metadata for a region is only loaded on the first time it is needed). +* Metadata for extended functionality is held in separate packages, which therefore need to be explicitly + loaded separately. This affects: + * The geocoding metadata, which is held in `phonenumbers.geocoder` and used by the geocoding functions + (`geocoder.description_for_number`, `geocoder.description_for_valid_number` or + `geocoder.country_name_for_number`). + * The carrier metadata, which is held in `phonenumbers.carrier` and used by the mapping functions (`carrier.name_for_number` + or `carrier.name_for_valid_number`). + * The timezone metadata, which is held in `phonenumbers.timezone` and used by the timezone functions (`time_zones_for_number` + or `time_zones_for_geographical_number`). + +The `phonenumberslite` version of the library does not include the geocoder, carrier and timezone packages, +which can be useful if you have problems installing the main `phonenumbers` library due to space/memory limitations. If you need to ensure that the metadata memory use is accounted for at start of day (i.e. that a subsequent on-demand load of metadata will not cause a pause or memory exhaustion): -* Force-load the geocoding metadata by invoking `import phonenumbers.geocoder`. -* Force-load the carrier metadata by invoking `import phonenumbers.carrier`. -* Force-load the timezone metadata by invoking `import phonenumbers.timezone`. * Force-load the normal metadata by calling `phonenumbers.PhoneMetadata.load_all()`. +* Force-load the extended metadata by `import`ing the appropriate packages (`phonenumbers.geocoder`, + `phonenumbers.carrier`, `phonenumbers.timezone`). The `phonenumberslite` version of the package does not include the geocoding, carrier and timezone metadata, which can be useful if you have problems installing the main `phonenumbers` package due to space/memory limitations. Project Layout -------------- + * The `python/` directory holds the Python code. * The `resources/` directory is a copy of the `resources/` directory from |