python-lsp/python-lsp-jsonrpc

Make `ujson` an optional dependency

karthiknadig opened this issue · 2 comments

Can ujson be moved to optional dependency? This is so that we can use python-lsp-jsonrpc in scenarios where we can only run pure python code. This will also make it easier to use in web assembly and allow packaging this in extensions for editors like VS Code.

Hey @karthiknadig, thanks for reporting. I'm sorry but we're not interested in doing this because:

  1. ujson gives a significant speed up over standard library json, and there are a lot of back and forth json-encoded communications between the pylsp server and clients.
  2. You can try to create Wasm packages for ujson so you can use it in web apps (Conda-forge, for instance, provides that service). I don't know how easy that could be, but it's certainly feasible (much more complex packages, such as Pandas and Scikit-learn, already provide Wasm packages).

@ccordoba12 Thanks for looking into this. My request was based on the code here where ujson has a fallback to json.

try:
import ujson as json
except Exception: # pylint: disable=broad-except
import json

I completely understand the advantages of using ujson. I think making it optional would allow for greater flexibility and usage of the python-lsp-jsonrpc package, particularly in situations where it needs to be packaged, such as in universal VSCode extension packages. This way, users can still enjoy the benefits of ujson while avoiding any limitations imposed by it being a required dependency.

I understand your decision and we will find an alternative solution that works best for us. Thank you for your time and efforts in maintaining this package. We do use this for testing LSP :) Thank you for considering my request.