[Tutor] Duplicate items in list

Manprit Singh manpritsinghece at gmail.com
Sun Oct 11 04:35:24 EDT 2020


Dear sir ,

Agreed
Regards
Manprit Singh

On Sun, Oct 11, 2020 at 1:48 PM Alan Gauld via Tutor <tutor at python.org>
wrote:

> On 11/10/2020 09:01, Manprit Singh wrote:
>
> > So the only downside is , it is slow ... But slowness really matters in
> > this particular case ?
>
> It's slow and uses more memory.
> Neither matters in this case(although might in others).
> But the other point is that it is less idiomatic than None.
>
> None is the most commonly used value in a scenario like this.
> That makes it more readable than object() where the reader a
> has to stop and think why that value has been chosen.
> Readability is important, more important than performance
> in most cases, but less important than reliability!
>
> So, if you are sure the list will not contain None, use None.
> If there is any possibility of the list containing None
> use object()
>
> --
> Alan G
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
> http://www.amazon.com/author/alan_gauld
> Follow my photo-blog on Flickr at:
> http://www.flickr.com/photos/alangauldphotos
>
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>


More information about the Tutor mailing list