Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
find hidden python files
#1
I have a built-in operation which is eating up 74% of the run time in my code and I'm having a very difficult time tracking down its location. If look at the pictures you'll see that there is an operation which is simply called __call__ and its located at line 394 of the reference.py file. Then you'll see the number 20 circled, that means 20 seconds and the program takes 33 seconds so that's how much time this operation is taking up. Then below that you'll see the four lines that use this feature and one of them is in _xlmac.py file. I cannot find either the _xlmac or the reference.py file. I think because they are hidden. If you put in those names into the mac spotlight those files do not come up.

Attached Files

Thumbnail(s)
   
Reply
#2
__call__ is a function call. Probably of a class, because a function would have it's name there instead. ie:
class Spam:
    def __call__(self, arg):
        print(f"Spam's instance was called: {arg}")

foo = Spam()
foo("__call__ is called here")
A quick google search shows that xlwings has a _xlmac.py file, but that doesn't mean that's the one you're seeing: https://github.com/ZoomerAnalytics/xlwings

How are you getting these numbers? Are you using an ide? The ide itself, or however your code is being analyzed might be contributing to the numbers.
Reply
#3
Yea, I'm using xlwings but that does not solve the larger problem of how to track down hidden python files. I've run into this problem before and need to add this skill to my repertoire. I've solved the problem. openpyxl opens my workbook and processes the data in 45 seconds. That's too slow. So I've moved over to the xlrd module. the xlrd module changes integers to floats so I had to add in the line:

float_x_int = lambda x: int(x) if type(x) in [float, int] and int(x) == x else x
After I put in that line the execution time went from 10 to 27 seconds. I had trouble believing that the above line would cause that but it turns out that it was an xlwings function I was using. I thought I was using the xlwings function before but apparently it wasn't.


Still, in the future I might need to have to locate a hidden python file and place a break point in them and then look in the stack to find out where the code is accessing that python module. So even though I've got the executing time down to a reasonable level, I still need to solve this larger problem.
Reply
#4
I actually just recently started looking at python debuggers, and Thonny might be a good place to start. https://thonny.org/
By stepping into the code, you can see exactly what lines are running, and when, so you can track down what's happening.
Reply
#5
Operating system?
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Copy only hidden files and folders with rsync Cannondale 2 993 Mar-04-2023, 02:48 PM
Last Post: Cannondale
  Find duplicate files in multiple directories Pavel_47 9 3,062 Dec-27-2022, 04:47 PM
Last Post: deanhystad
  Can ZipFile be used to extract hidden files? AiedailEclipsed 0 1,609 Mar-22-2022, 05:21 PM
Last Post: AiedailEclipsed
  count every 28 files and find desire files RolanRoll 3 2,063 Dec-12-2021, 04:42 PM
Last Post: Axel_Erfurt
  Have to use Python 2.x to find "yesterday' files tester_V 6 2,815 Sep-19-2021, 12:26 AM
Last Post: tester_V
  find 'yesterdays files' tester_V 8 3,810 Jun-18-2021, 02:10 AM
Last Post: tester_V
  Find and replace in files with regex and Python Melcu54 0 1,844 Jun-03-2021, 09:33 AM
Last Post: Melcu54
  List of error codes to find (and count) in all files in a directory tester_V 8 3,658 Dec-11-2020, 07:07 PM
Last Post: tester_V
  helping PyInstaller To Find files Harshil 0 1,478 Aug-30-2020, 10:16 AM
Last Post: Harshil
  Find specific subdir, open files and find specific lines that are missing from a file tester_V 8 3,549 Aug-25-2020, 01:52 AM
Last Post: tester_V

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020