Re: [sympy] Coding guidelines

2019-09-08 Thread Oscar Benjamin
I should clarify that what I said is opinionated (my opinion in particular!) so it's possible others disagree. Certainly there is a lot of code in SymPy that doesn't follow the advice above. If we want a cached_property decorator then we can add this somewhere in sympy/utilities or perhaps

Re: [sympy] Coding guidelines

2019-09-08 Thread Rybalka Denys
Great, that is exactly what I've been trying to find! By the way, there is caching property decorator called `@cached_property`, that does exactly what you suggested. It is, however, not in the standard library (https://pypi.org/project/cached-property/). Maybe it would be beneficial to add it to

Re: [sympy] Coding guidelines

2019-09-08 Thread Oscar Benjamin
Preventing assignment isn't necessary for the internal workings of SymPy. The only advantage it has is potentially avoiding confusion for users. I don't particularly see users getting confused about this though (although maybe that's because of the widespread use of properties). What I think is

[sympy] Coding guidelines

2019-09-08 Thread Rybalka Denys
There are several ways to implement properties of sympy objects. The simplest one is: ``` def __new__(*args): obj = Basic(*args) obj.prop = 'some_property' ``` A slightly more complicated one is: ``` def __new__(*args): obj = Basic(*args) obj._prop = 'some_property' @property def