Bug 1970521 Comment 0 Edit History

Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.

Bug 1970516 added the `orjson` compatibility shim used by `taskgraph` to `mozfile`.

`orjson` is considerably faster than the stdlib `json`, so let's use it everywhere we can in `firefox`. Here's a [searchfox query](https://searchfox.org/mozilla-central/search?q=import%5Cs%2Bjson%7Cfrom%5Cs%2Bjson%5Cs&path=&case=true&regexp=true) that should find all instances of `import json` or `from json`. In most cases, we should be able to just replace that with `from mozfile import json` or `from mozfile.json import <function>` and it should just work. One caveat is that the interface for `orjson` is not identical to the stdlib `json`, it only supports `ident=2` and the `sort_keys` arguments.

If `orjson` is not compatible with how `json` is being used then the stdlib `json` will have to stay (but in some cases a file may need both, in that case use `from mozfile import json as mozfile_json` and update the `orjson` compatible code accordingly).

Here's an example patch of what was done in `taskgraph`: https://phabricator.services.mozilla.com/D251628

Most changes should follow a very similar formula, but they must be tested.

Future contributors 👋
For using this meta bug, let's follow the same pattern as bug 1714690 did for the `six` removals. Pick a directory with files that need this change and leave a comment here indicating that you want to work on that. Then either make your own bug or we'll do it and assign it to you. It should be titled something like `Use 'mozfile.json' throughout 'python/mozbuild'`. All the changes that need to be done in [python/mozbuild](https://searchfox.org/mozilla-central/source/python/mozbuild) will then be done under that bug.

Others could be `python/mozboot`, `python/mach`, `js/src`, etc.

Feel free to reach out to me if you have any questions.
Bug 1970516 added the `orjson` compatibility shim used by `taskgraph` to `mozfile`.

`orjson` is considerably faster than the stdlib `json`, so let's use it everywhere we can in `firefox`. Here's a [searchfox query](https://searchfox.org/mozilla-central/search?q=import%5Cs%2Bjson%7Cfrom%5Cs%2Bjson%5Cs&path=&case=true&regexp=true) that should find all instances of `import json` or `from json`. In most cases, we should be able to just replace that with `from mozfile import json` or `from mozfile.json import <function>` and it should just work. One caveat is that the interface for `orjson` is not identical to the stdlib `json`, it only supports `ident=2` and the `sort_keys` arguments.

If `orjson` is not compatible with how `json` is being used then the stdlib `json` will have to stay (but in some cases a file may need both, in that case use `from mozfile import json as mozfile_json` and update the `orjson` compatible code accordingly).

Here's an example patch of what was done in `taskgraph`: https://phabricator.services.mozilla.com/D251628

Most changes should follow a very similar formula, but they must be tested.

Future contributors 👋
For using this meta bug, let's follow the same pattern as bug 1714690 did for the `six` removals. Pick a directory with files that need this change and leave a comment here indicating that you want to work on that. Then either make your own bug or we'll do it and assign it to you. It should be titled something like `Use 'mozfile.json' throughout 'python/mozbuild'`. All the changes that need to be done in [python/mozbuild](https://searchfox.org/mozilla-central/source/python/mozbuild) will then be done under that bug.

Others could be `python/mozboot`, `python/mach`, `js/src`, etc.

Feel free to reach out to me if you have any questions.

Note: Bug 1970521 is a dependency to this, until [D252609](https://phabricator.services.mozilla.com/D252609) lands you will need to base your changes on my patch. You can grab my patch from Phabricator using `moz-phab` with the following command: `moz-phab patch --apply-to=here D252609`
Bug 1970516 added the `orjson` compatibility shim used by `taskgraph` to `mozfile`.

`orjson` is considerably faster than the stdlib `json`, so let's use it everywhere we can in `firefox`. Here's a [searchfox query](https://searchfox.org/mozilla-central/search?q=import%5Cs%2Bjson%7Cfrom%5Cs%2Bjson%5Cs&path=&case=true&regexp=true) that should find all instances of `import json` or `from json`. In most cases, we should be able to just replace that with `from mozfile import json` or `from mozfile.json import <function>` and it should just work. One caveat is that the interface for `orjson` is not identical to the stdlib `json`, it only supports `ident=2` and the `sort_keys` arguments.

If `orjson` is not compatible with how `json` is being used then the stdlib `json` will have to stay (but in some cases a file may need both, in that case use `from mozfile import json as mozfile_json` and update the `orjson` compatible code accordingly).

Here's an example patch of what was done in `taskgraph`: https://phabricator.services.mozilla.com/D251628

Most changes should follow a very similar formula, but they must be tested.

Future contributors 👋
For using this meta bug, let's follow the same pattern as bug 1714690 did for the `six` removals. Pick a directory with files that need this change and leave a comment here indicating that you want to work on that. Then either make your own bug or we'll do it and assign it to you. It should be titled something like `Use 'mozfile.json' throughout 'python/mozbuild'`. All the changes that need to be done in [python/mozbuild](https://searchfox.org/mozilla-central/source/python/mozbuild) will then be done under that bug.

Others could be `python/mozboot`, `python/mach`, `js/src`, etc.

**Beware**: various files in that searchfox query come from `third_party` code. If there's `third_party` anywhere on the path of a file, it's almost guaranteed that you don't want to makes changes that file.

Feel free to reach out to me if you have any questions.

Note: Bug 1970521 is a dependency to this, until [D252609](https://phabricator.services.mozilla.com/D252609) lands you will need to base your changes on my patch. You can grab my patch from Phabricator using `moz-phab` with the following command: `moz-phab patch --apply-to=here D252609`
Bug 1970516 added the `orjson` compatibility shim used by `taskgraph` to `mozfile`.

`orjson` is considerably faster than the stdlib `json`, so let's use it everywhere we can in `firefox`. Here's a [searchfox query](https://searchfox.org/mozilla-central/search?q=import%5Cs%2Bjson%7Cfrom%5Cs%2Bjson%5Cs&path=&case=true&regexp=true) that should find all instances of `import json` or `from json`. In most cases, we should be able to just replace that with `from mozfile import json` or `from mozfile.json import <function>` and it should just work. One caveat is that the interface for `orjson` is not identical to the stdlib `json`, it only supports `ident=2` and the `sort_keys` arguments.

If `orjson` is not compatible with how `json` is being used then the stdlib `json` will have to stay (but in some cases a file may need both, in that case use `from mozfile import json as mozfile_json` and update the `orjson` compatible code accordingly).

Here's an example patch of what was done in `taskgraph`: https://phabricator.services.mozilla.com/D251628

Most changes should follow a very similar formula, but they must be tested.

Future contributors 👋
For using this meta bug, let's follow the same pattern as bug 1714690 did for the `six` removals. Pick a directory with files that need this change and leave a comment here indicating that you want to work on that. Then either make your own bug or we'll do it and assign it to you. It should be titled something like `Use 'mozfile.json' throughout 'python/mozbuild'`. All the changes that need to be done in [python/mozbuild](https://searchfox.org/mozilla-central/source/python/mozbuild) will then be done under that bug.

Others could be `python/mozboot`, `python/mach`, `js/src`, etc.

Feel free to reach out to me if you have any questions.

Note: Bug 1970521 is a dependency to this, until [D252609](https://phabricator.services.mozilla.com/D252609) lands you will need to base your changes on my patch. You can grab my patch from Phabricator using `moz-phab` with the following command: `moz-phab patch --apply-to=here D252609`
Bug 1970516 added the `orjson` compatibility shim used by `taskgraph` to `mozfile`.

`orjson` is considerably faster than the stdlib `json`, so let's use it everywhere we can in `firefox`. Here's a [searchfox query](https://searchfox.org/mozilla-central/search?q=import%5Cs%2Bjson%7Cfrom%5Cs%2Bjson%5Cs&path=&case=true&regexp=true) that should find all instances of `import json` or `from json`. In most cases, we should be able to just replace that with `from mozfile import json` or `from mozfile.json import <function>` and it should just work. One caveat is that the interface for `orjson` is not identical to the stdlib `json`, it only supports `ident=2` and the `sort_keys` arguments.

If `orjson` is not compatible with how `json` is being used then the stdlib `json` will have to stay (but in some cases a file may need both, in that case use `from mozfile import json as mozfile_json` and update the `orjson` compatible code accordingly).

Here's an example patch of what was done in `taskgraph`: https://phabricator.services.mozilla.com/D251628

Most changes should follow a very similar formula, but they must be tested.

Future contributors 👋
For using this meta bug, let's follow the same pattern as bug 1714690 did for the `six` removals. Pick a directory with files that need this change and leave a comment here indicating that you want to work on that. Then either make your own bug or we'll do it and assign it to you. It should be titled something like `Use 'mozfile.json' throughout 'python/mozbuild'`. All the changes that need to be done in [python/mozbuild](https://searchfox.org/mozilla-central/source/python/mozbuild) will then be done under that bug.

Others could be `python/mozboot`, `python/mach`, `js/src`, etc.

Feel free to reach out to me if you have any questions.

Back to Bug 1970521 Comment 0