[Numpy-discussion] Remove numpy/compat/_inspect.py ?

Charles R Harris charlesr.harris at gmail.com
Fri Aug 1 09:54:06 EDT 2014


On Fri, Aug 1, 2014 at 7:03 AM, Charles R Harris <charlesr.harris at gmail.com>
wrote:

>
>
>
> On Fri, Aug 1, 2014 at 6:37 AM, Robert Kern <robert.kern at gmail.com> wrote:
>
>> On Fri, Aug 1, 2014 at 12:57 PM, Charles R Harris
>> <charlesr.harris at gmail.com> wrote:
>> >
>> > On Thu, Jul 31, 2014 at 11:46 PM, David Cournapeau <cournape at gmail.com>
>> > wrote:
>> >>
>> >> The docstring at the beginning of the module is still relevant AFAIK:
>> it
>> >> was about decreasing import times. See
>> >>
>> http://mail.scipy.org/pipermail/numpy-discussion/2009-October/045981.html
>> >>
>> >>
>> >> On Fri, Aug 1, 2014 at 10:27 AM, Charles R Harris
>> >> <charlesr.harris at gmail.com> wrote:
>> >>>
>> >>> Hi All,
>> >>>
>> >>> The _inspect.py function looks like a numpy version of the python
>> inspect
>> >>> function. ISTR that is was a work around for problems with the early
>> python
>> >>> versions, but that would have been back in 2009.
>> >>>
>> >>> Thoughts?
>> >>>
>> >
>> > It's only used in one function.
>>
>> Yes, one function that is called at startup, so no, a local import of
>> the stdlib inspect module would not help.
>>
>> > def get_object_signature(obj):
>> >     """
>> >     Get the signature from obj
>> >     """
>> >     try:
>> >         sig = formatargspec(*getargspec(obj))
>> >     except TypeError as errmsg:
>> >         sig = ''
>> > #        msg = "Unable to retrieve the signature of %s '%s'\n"\
>> > #              "(Initial error message: %s)"
>> > #        warnings.warn(msg % (type(obj),
>> > #                             getattr(obj, '__name__', '???'),
>> > #                             errmsg))
>> >     return sig
>> >
>> > Where a local import would do as well. It also has bugs, so evidently
>> isn't
>> > called often ;)
>>
>> What bugs? Any bugs relevant to the objects that
>> get_object_signature() is called with? It does not have to work for
>> anything else but those.
>>
>
> Undefined variables in getargs. The only two functions used from the
> module are very small and could simply be brought into `ma/core.py`. The
> python inspect module is used elsewhere...
>

Importing inspect looks to take about  500 ns on my machine. Although It is
hard to be exact, as I suspect the file is sitting in the file cache. Would
probably be slower with hard disks. But as the inspect module is already
imported elsewhere, the python interpreter should also have it cached.

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20140801/ead2e2f6/attachment.html>


More information about the NumPy-Discussion mailing list