[SciPy-Dev] usage of inspect.getargspec ?

josef.pktd@gmai... josef.pktd@gmai...
Fri Jan 6 23:21:31 CST 2012

On Fri, Jan 6, 2012 at 10:05 PM, Travis Oliphant <travis@continuum.io> wrote:
> For the record, I don't think you are being inappropriately grumpy.   Your feedback is exactly the kind required and valued.   If you think something stinks, you should speak up.  Olfactory sensors can be damaged in others.
> This discussion is about at least 2 things as far as I can see:
>        1) Using an API that allows a single callable to have different signatures and purposes
>        2) Using inspect.getargspec
> Clearly inspect is seen as too fragile.  I don't disagree.  I don't weight the impact of that as highly as others in this particular case.
> But, is it also felt that #1 is untenable?

My feeling is that #1 is much more a taste question (compared to #2),
if it can be made to be robust enough.
I don't like it and I still don't really see the reason for merging
the two functions in an internal function, _minimize_newtoncg. I agree
with both Nathaniel, that these are clearly two different call back
functions, and with Robert, that given the docstring the usage of hess
versus hess_p should be pretty clear.
(if they are two different functions, don't call them the same thing, or so.)

On the other hand we are using type checking in scipy (and
statsmodels) to dispatch to different code paths. But my imagination
is not good enough to see how robust for example the "try ... except
TypeError ... else ..."  is, (in contrast to inspect which I know will
create problems with high probability, and type checking which is
pretty predictable. Or, to paraphrase Warren, in the latter case, the
developer doesn't get confused about what the function is doing in
different cases.)


> -Travis
> On Jan 6, 2012, at 12:48 PM, josef.pktd@gmail.com wrote:
>> On Fri, Jan 6, 2012 at 10:42 AM,  <josef.pktd@gmail.com> wrote:
>>> On Fri, Jan 6, 2012 at 10:37 AM, Gael Varoquaux
>>> <gael.varoquaux@normalesup.org> wrote:
>>>> On Fri, Jan 06, 2012 at 03:11:26PM +0000, Robert Kern wrote:
>>>>>> My view is that simple things should be simple --- especially for the occasional user.
>>>>> My main problem with this view is that I don't think that whether you
>>>>> need a Hessian or not is the reasonable line to draw between "simple
>>>>> things" and "not so simple things". The problem with using
>>>>> getargspec() is that it is unreliable. It doesn't work for many
>>>>> reasonable inputs (like say a wrapper function that wraps the real
>>>>> function with one that takes *args,**kwds or extension functions or
>>>>> bound methods or objects with __call__). Knowing that you have one of
>>>>> these cases requires some rather deep experience with Python.
>>> Just to illustrate the problem: a question with inspect by a stackoverflow user
>>> http://stackoverflow.com/questions/7615733/too-many-arguments-used-by-python-scipy-optimize-curve-fit
>> and, I'm sorry if I sound grumpy at times.
>> I'm spending a large amount of time on code maintenance, and this
>> change promises several days of bug hunting, finding work-arounds and
>> answering questions on stack overflow for no clear benefits that I can
>> see, so I'd rather announce my opinion in advance.
>> Josef
>>> Josef
>>>> I feel like Robert.
>>>> In addition, I have always disliked the magic that traits did on the
>>>> number of arguments: I was always unsure of what was going on.
>>>> Better explicit than implicit.
>>>> My 2 euro-cents (kindly provided by the European Financial Stability
>>>> Facility)
>>>> Gaël
>>>> _______________________________________________
>>>> SciPy-Dev mailing list
>>>> SciPy-Dev@scipy.org
>>>> http://mail.scipy.org/mailman/listinfo/scipy-dev
>> _______________________________________________
>> SciPy-Dev mailing list
>> SciPy-Dev@scipy.org
>> http://mail.scipy.org/mailman/listinfo/scipy-dev
> _______________________________________________
> SciPy-Dev mailing list
> SciPy-Dev@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-dev

More information about the SciPy-Dev mailing list