News for hackers. Stuff that matters.
Re:Python Lists vs. Tuples by omaranto on Saturday August 20, 2016 @01:50AM (#12325397)
I thought Ruby ensured there was only one symbol with given contents, so that equality testing for symbols reduces to pointer equality. I don't Python strings behave that way.

But at any rate I wasn't thinking of performance characteristics but rather the stereotypical uses of symbols vs strings in languages that have both, so you are right that one can use Python strings in place of symbols, as SpaceManiac already pointed out above.

Re:Python Lists vs. Tuples by BerislavLopac on Saturday August 20, 2016 @07:26AM (#12326078)
> I thought Ruby ensured there was only one symbol with given contents, so that equality testing for symbols reduces to pointer equality. I don't Python strings behave that way.

In Python, string literals are reused, if that is what you meant.

    >>> a = 'abc'
    >>> b = 'abc'
    >>> a is b
    True
Re:Python Lists vs. Tuples by gsnedders on Saturday August 20, 2016 @04:29PM (#12328185)
This isn't guaranteed by the language, even if CPython does it. What is guaranteed is intern('abc') is intern('abc').
Re:Python Lists vs. Tuples by infinite8s on Saturday August 20, 2016 @11:15AM (#12326937)
String literals up to a certain size are reused.
Re:Python Lists vs. Tuples by omaranto on Saturday August 20, 2016 @02:06PM (#12327659)
Oh, cool, I didn't know that. I think in Ruby all symbols are reused, whether they are literals or constructed programatically. (Unlike Common Lisp symbols which can also de 'uninterned' if they are not literals.)