TicTacToe with Python
I guess from efficiency point of view this is fine, even that last line. Efficiency points:


You create player variable as list and then keep converting to set over and over again, why not have it as set from beginning?


From readability and maintenance point of view, you are having lots of duplicities.


Player moves are exactly same except for message and variable, you can extract that to function.
Same goes for checking if a player won.
I don't like variable w. Why not make variable winner instead and save name of winner into it? Related to extracting if player won to separate function.


And for your last line - you can put all possible winning combinations into array or tupple and then check that in cycle (you get the idea):

winning_combinations = [
[1, 2, 3],
[4, 5, 6],
...
]