On Tue, Jul 7, 2020 at 12:53 PM Stephen J. Turnbull
<turnbull.stephen...@u.tsukuba.ac.jp> wrote:
>
> Christopher Barker writes:
>
>  > I meant in the context of putting things in, or testing whether they are
>  > in, sets. Not in any other context.
>
> OK, but restricting context that way is asking for eventual trouble,
> because there's one more thing you can do with sets: get stuff out of
> them (by iterating).
>
>  > But to see if I understand correctly, you couldn’t quite use a set to
>  > intern objects: once 2.0 was in there you could not put 2 in as
>  > well.
>
> Good point.  You could delete one and replace it with the other, but
> not have both.  That does kind of defeat the whole idea of the
> "intern" nomenclature.
>

"Interning" is usually only done with strings. To get a similar
effect, you could put (type(x), x) into the tuple, which would allow
you to have both the int 2 and the float 2.0 in the interning set. Or
have separate sets for different types.

ChrisA
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/BIWJ2KWJ5FLEU2ZCBKU26FY6LSESPBLE/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to