The nearest thing to an id for a file (some unique number identifying the file in the filesystem) is called an inode, that's indeed the number returned by stat in the field st_ino.
This number may change in some circumstances even if the name of the file does not, for instance when the file is replaced by another one (copy), or deleted and recreated.
This number won't change if you merely open the file and perform reads and writes over it.
CHeck here for more detailed explanation about inodes https://github.com/angrave/SystemProgramming/wiki/File-System,-Part-2:-Files-are-inodes-(everything-else-is-just-data...)
Also notice that not all filesystems have inodes, this is a concept that originated on Unix. There is no such thing with vfat.
If you are only interested about the filename, another way to get a unique number is expanding the filename to it's full path up to the filesystem root (or drive on windows), then calling hash()
on the string.
What you are losing doing that is that on some filesystems a given file on disk may be reached using several names (hardlinks or softlinks, I won't expand here on the differences). Depending on you use case it may or may not be a problem.
If you are looking for files with the same content, that's yet another story. Filesystems don't care for the content of the file. To know if two files are identical you'll have to open them and compare them. Using python you should have a look at filecmp
module.
A common way to compare many files is relying on a hash signature of the file content. For instance have a look at that answer to see how to do that for MD5 (a bit outdated, but easily adapted to more modern signatures) Generating a MD5 signature of a file