[Tutor] Duplicate items in list

Alan Gauld alan.gauld at yahoo.co.uk
Sun Oct 11 03:54:55 EDT 2020


On 11/10/2020 03:40, Manprit Singh wrote:

> Here If the List is starting from None then it is more safer to take last =
> object(). Need to know why it should not be preferred ? Any specific reason
The downside to object() is that it is comparatively expensive. It
constructs a new instance of object which consumes more memory than
None(a singleton instance) and is slower. That's why the normal
sentinel/initializer value in Python is None.

But it does run the risk, as in this case, that the data could
contain none. So in that scenario object() would be a more reliable
option.

-- 
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




More information about the Tutor mailing list