Faster, Efficient way to indexing and renewing

reproducible code :

import torch
x = torch.rand(3)
print(x)
# tensor([0.5647, 0.7095, 0.4463])

x[x>0.5] = 1
print(x)
# tensor([1.0000, 1.0000, 0.4463])

I’m looking for a faster/efficient way to do the x[x>0.5] = 1.

Thanks in advance.