why function throws an error?
Mirko
mirkok.lists at googlemail.com
Tue Jun 28 05:11:24 EDT 2022
Am 28.06.22 um 09:57 schrieb נתי שטרן:
> def add_route(self, route):
> # """ Add a route object, but do not change the :data:`Route.app`
> # attribute."""
> self.routes.append(route)
> self.router.add(route.rule, route.method, route, name=route.name
> )
> # if DEBUG: route.prepare()
> --
> <https://netanel.ml>
Are you still trying to combine different modules into one large
module? That is not going to help you. First, you need to rewrite
all those modules to seamlessly work together. This will likely be a
huge task. Let's say you have a module that defines some function
route():
def route():
print("route")
Another module defines a variable called "route":
route = True
A third module needs to call the function from the first module, but
this fails now because the second module has overwritten (shadowed)
the former function with a variable:
route = True
route()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'bool' object is not callable
You would need to find all those cases where one module overwrites
variables or functions from other modules. And sometimes those cases
will be difficult to spot. Python is not designed for what you are
trying to do. Even if you get this done, it will not help you. You
can't just throw everything into a single file and then magically
optimize it. When you have this huge final module, what do you think
you can do with it to be faster?
If you have performance problems with some module, you have several
options to optimize it:
- Find a better algorithm.
- Rewrite performance-critical parts in Cython or even C and import
the compiled module.
- Use a JIT compiler such as PyPy
More information about the Python-list
mailing list