On Sat, Mar 1, 2014 at 6:09 PM, Alexander Belopolsky <ndar...@mac.com>wrote:

> On Fri, Feb 28, 2014 at 10:34 AM, Chris Barker - NOAA Federal <
> chris.bar...@noaa.gov> wrote:
>
>>
>> Whatever happened to duck typing?
>>
>
> http://legacy.python.org/dev/peps/pep-3119/#abcs-vs-duck-typing
>

Sure -- but I'm afraid that there will be a lot of code that does
an isinstance() check where it it absolutely unnecessary. If you really
need to know if something is a sequence or a mapping, I suppose it's
required, but how often is that?

I suppose there are two sides to this coin:

1) Should numpy arrays use the ABC properly so that client code
will recognise them as sequences -- probably, yes -- why not?
(though the trick here is that numpy arrays do act differently than other
mutable sequences -- view semantics and all -- so I think it's kind of
dangerous)

2) If you are writing client code, should you use an isinstance() check
passed-in objects? -- probably not!

-CHB


-- 

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

chris.bar...@noaa.gov
_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to