If it has to be the same both in pinout and functionality, then you do not give yourself much room for selecting another one.
It's quite common to respin a PCB to optimize for production costs.
Just recently I also did a short comparison between some different STM32 models. The reason I did this is that I want to make my own develop / breakout board and I was curious how many different chips would fit on it, and curiousity to general pin compatibility between STM32 models.
When you have STM Cube open, you can easily sort on package size, peripherals, Flash, RAM, etc.
For the pinout, I found out that just loading the chips in KiCad was the quickest (any other PCB program with libraries for those chips should work too)
If you want the pins in a table in a spreadsheet format, that is also easy to do from KiCad:
1. Select the symbol on the KiCad schematic.
2. Press Ctrl + E to load it in the schematic editor.
3. Symbol Editor / Edit / Pin table
4. Sort on pin number.
5. Select all the fields in the "name" column.
6. Copy the column, and paste it in a spreadsheet.
7. Close the Symbol Editor without saving, and then repeat with some other IC.
In the screenshot below, I mirrored the STM32F303R6Tx and you see immediately it has one less IO pin. The 446RCT has Pin 30 as a VCAP_1 as some other function.
In KiCad you can also narrow the selection with multiple (partial) search terms.
For example: stm32f3 and tqfp64", and this narrows it down to about 30 models in KiCad.
Also, scrolling through the list immediately shows the pinout preview in the right which also helps with pinout comparison.
Also, when differences are very small (such as with the VCAP_1 pin) you may be able to just leave such a pin open in your design, or plan a few 0 ohm resistors into the design for variants. But I'm not sure if planning that far ahead is useful.