I am writing a small .py file that contains some classes to be imported later repetitively into other work. The mentioned .py file uses some small database (in order of KB) in the form of tables. Do you think it is better to store this data in the same .py file or is it better to keep it in a separate .csv file? What are the differences in terms of performance and convenience for later use? A point that I might have to mention is that this data is numerical and is not prone to any possible change in the future.
Single items are to be accessed from this data at a time.
If readability of the python class is not a concern (although it's best practice to keep code as readable as possible), the big question here will be 'how much' data are we talking about? If you have gigabytes of data then you don't want to have this all sitting in memory at the same time (i.e. what would happen if you just kept it as a constant in a .py file). Instead, for such large data, you want to read it from disk (maybe as a csv) as and when you need it.
Of course storing it in disk has a performance hit because reading from disk is slower than reading from memory. Whether or not the performance hit is okay for your application is up to you to decide.
A good in-between to ensure readability and good performance might be (assuming you have enough memory) to store the data in a csv, read it all at once on start up and keep it in memory for repeated calls.
Should I be saving my data in a .csv file?