New answers tagged

1

A few things to consider whether to directly import the backbone or use the API layer. How many components are dependent on backbone.py? How will the change in the backbone affect your component? If you can directly access to backbone.py, what is the need for backbone-api.py? If this is acting as a layer of abstraction to decouple different-angle from the ...


-1

I am not familiar with Python, but I suspect that saying CPython is an implementation of Python is the same as saying GCC is an implementation of ANSI Standard C and LAM MPI, MPICH, OpenMPI are implementations of the MPI specification. A programming language is specified by some standard-setting body and "implemented" by compilers or interpreters (...


0

Many-to-one relations are exactly the kind of relations that exist between instances-to-class, or derivedClasses-to-parentClass. They modelize a hierarchy (children-to-parent)and a dependency with a referential constraint: The parent should first be created: you may decide what will happen to the parent when no children are created or all of them have been ...


1

A few comments and recommendations: 'Sophisticated logic' in a constructor give me a little pause. Experience tells me to avoid lots of complexity in initializers. I would prefer a factory method on the module, for example, and make the creation of the Problem the last step. On a related note, I don't see a good reason to set a Problem globally on the ...


2

There are three factors at play: performing fewer large request tends to have higher throughput waiting for a buffer to fill up increases latency buffers require RAM This is a multi-objective optimization problem: we want to maximize throughput and minimize latency, subject to the constraint that there has to be enough free memory. However, that is a multi-...


3

There are two things going on in your function: composing the filters, and filtering the list. These are two distinct phases, and thus can easily be refactored into two methods: compose_filters which takes the five args, and filter_list which takes the aggregated filter and applies it. Separating compose_filters means you have a clear path to testing: pass ...


3

Let me assume by providing the right values to list, it should be simple to deduce from the returned value of the function whether a certain filter was applied, or not. If the filters are very complex functions, you may need to replace them by injecting some mock filters during the test to reach that goal, but that should be pretty straightforward. From this ...


2

Perhaps I have a more elegant solution for you, based on my understanding of the problem. Do not hesitate to tell me if I'm off. Optionally, you can have your pipelines in a standalone git project. Don't do that if it's too difficult to detangle dependencies, but it may make sense. Store the git tag or commit id corresponding to the pipeline version inside ...


2

what i know is , in cpython when we run a code then its first compiled into byte code and the cpython interpreter( which is written in c interprets it) interprets the byte code and converts it into machine code. No, it doesn't "convert it into machine code." That would be a compiler, not an interpreter. A compiler is a program which takes a ...


5

For all practical purposes, bytecode is just a data structure that is convenient for an interpreter to use. The interpreter looks at each instruction in the byte code and immediately performs that action. A simple interpreter for arithmetic expressions might look like this when written in Python: bytecode = [ {'type': 'const', 'value': 40}, {'type': '...


0

Conceptually, a bytecode interpreter has a big switch() statement at its core where each case corresponds to one bytecode. Just-in-time implementations get better performance by translating a sequence of bytecodes to machine language and calling the generated code (which may be cached) instead of interpreting. Translating bytecodes to C and compiling that ...


2

Is DefaultEngine deterministic and side effect free? Will it always be? Many things can be considered a unit for a unit test but if you can’t predict what the unit will do it’s a poor unit. That said, a unit can be far more than a single class. We’re testing an abstraction not how it works. Now if DefaultEngine simply must be mocked... well it’s nicer if it’...


1

Before you start thinking in terms of "MySQL tables", the first step is to clearly identify the entities and relationships in your system. I don't know anything about Uber's actual process, and there are many more factors than I'll mention here, but at its core, we have this: Drivers. A driver is an entity that has a Location and Availability. The ...


1

Well, you don't need distances at all. You could simply do: def points_in_rad(coord_list, center, radius): return (coord for coord in coord_list if distance(coord, center) <= radius) ... although I think it would be more readable like this: def points_in_rad(coord_list, center, radius): for coord in coord_list: if distance(coord, center) &...


0

I hate writing this but.. "It depends on your use case". The underlying question here is how static is your list of places? if you delete a place will you want to delete all the events that ever took place at that place? I think that generally "places" are pretty vague things and the non-relational approach of storing the place in the ...


2

If you're not going to put weights on the rule set, I believe something like this should work: Rule1: (0 / 1) Rule2: (0 / 1) Rule3: (0 / 1) Rule4: (0 -> 3) (or 0 / 1 / 2 if XOR, failing on 0) Rule4a: 2 Rule4b: 1 Rule5: (sum of subrules: 0 -> 7) # every value matches to a unique case (f.e.: 5b + 5c = 3), # every sub-rule value is ...


Top 50 recent answers are included