rigetti / pyquil

A Python library for quantum programming using Quil.
http://docs.rigetti.com
Apache License 2.0
1.4k stars 342 forks source link

Use implicit namespace for pyquil, allowing for separation of submodules #1062

Open notmgsk opened 5 years ago

notmgsk commented 5 years ago

It would be nifty if the pyquil namespace was open to all. Take for example, the pyquil.operator_estimation code: it is useful, but also niche and could reasonably live externally to the base pyquil package as a sort of extension to pyquil. That is, pyquil/operator_estimation.py might live at a different location (and a different git repo), say in a package called "pyquil-operator-estimation". Then you would pip install pyquil-operator-estimation and import pyquil.operator_estimation, etc. The directory structure for pyquil-operator-estimation would look something like

pyquil-operator-estimation/
  - pyquil/
    - operator_estimation.py

Python does in fact enable this kind of common namespace packaging of dislocated source trees via PEP 420 (blazeit). And the only change we would need to make would be to remove the file pyquil/__init__.py and replace its functionality.

The operator estimation stuff above is just an example, and I wouldn't necessarily suggest that we make that change since it would be backwards incompatible (though I expect operator estimation users are few and far between). What prompted this thought was an interest in extending pyquil (the library) to include tools that would for example convert cirq to quil, etc. That stuff really doesn't need to live in pyquil main, but it would be nice to have it under the pyquil namespace in python.

The downsides are:

karalekas commented 5 years ago

This is the idea behind forest-benchmarking -- to use "forest" as a namespace package.