On Sun, Jun 20, 2021, at 20:46, Gagandeep Singh wrote:
> I have recently joined the mailing list and have gone through the previous discussions on this thread. I would like to share my analysis (advantages and disadvantages) of three possible alternatives (Enum, String, boolean) to support the proposed feature.
Thanks for this thorough analysis, Gagandeep!
I'll throw one more heretical idea out there:
`np.copy.IF_NEEDED`, `np.copy.ALWAYS`, `np.copy.NEVER`.
This has the advantages of the enum, doesn't pollute the global namespace, and has an intuitive name.
It would be slightly more awkward to type, but is doable. A rough Python version sketch would be:
IF_NEEDED = 0
ALWAYS = 1
NEVER = 2
IF_NEEDED : CopyFlag = CopyFlag.IF_NEEDED
ALWAYS : CopyFlag = CopyFlag.ALWAYS
NEVER : CopyFlag = CopyFlag.NEVER
def __call__(self, x):
return ...whatever copy returns...
np.copy = NpCopy()
NumPy-Discussion mailing list