[Python-Dev] PEP czar for PEP 3144?
Guido van Rossum
guido at python.org
Mon Mar 19 22:21:50 CET 2012
On Mon, Mar 19, 2012 at 1:13 PM, Ethan Furman <ethan at stoneleaf.us> wrote:
> Guido van Rossum wrote:
>>
>> On Mon, Mar 19, 2012 at 12:37 PM, Ethan Furman <ethan at stoneleaf.us> wrote:
>>>
>>> Nick Coghlan wrote:
>>>>
>>>> Collapsing the address list has to build the result list anyway to
>>>> actually handle the deduplication part of its job, so returning a
>>>> concrete list makes sense in that case.
>>>
>>>
>>> Having only one function return a list instead of an iterator seems
>>> questionable.
>>>
>>> Depending on the code it could either keep track of what it has returned
>>> so
>>> far in a set and avoid duplication that way; or, just return an
>>> `iter(listobject)` instead of `listobject`.
>>
>>
>> I know I'm lacking context, but is the list ever expected to be huge?
>> If not, what's wrong with always returning a list?
>
>
> Nothing wrong in and of itself. It just seems to me that if we have several
> functions that deal with ip addresses/networks/etc, and all but one return
> iterators, that one is going to be a pain... 'Which one returns a list
> again? Oh yeah, that one.'
It depends on whether they really are easy to confuse. If they are,
indeed that feels like poor API design. But sometimes the only time
two things seem confusingly similar is when you have not actually
tried to use them.
A naming convention often helps too.
> Granted it's mostly a stylistic preference for consistency.
And remember that consistency is good in moderation, but if it becomes
a goal in itself you may have a problem.
--
--Guido van Rossum (python.org/~guido)
More information about the Python-Dev
mailing list