Deleted thousands of photos from Photos library, and the size is the same I have a a Photos library which is around 335GB.

I deleted 23k photos from it (leaving only the photos from 2015-2016) and the size is almost the same: now the size is 330GB.

After deleting them I also emptied the Recently Deleted album.

How to solve this? How to speed up the deletion process?

Using the latest Photos and macOS versions.
Photos does not reclaim disk spaces immediately after you empty the Recently Deleted folder. Keep Photos opened and allow it to reclaim the disk space. It does take some time. I believe that they are the image caches, thumbnails, indices for searching and all other metadata files being cleaned up in the background. There are a lot of layers to how the photos are stored, so there is a lot of different files to clean up. I'd connect to the ac power and just don't let your disk or computer go to sleep.