Do function pointers force an instruction pipeline to clear?

On some processors an indirect branch will always clear at least part of the pipeline, because it will always mispredict. This is especially the case for in-order processors. For example, I ran some timings on the processor we develop for, comparing the overhead of an inline function call, versus a direct function call, versus an … Read more

Pipe complete array-objects instead of array items one at a time?

Short answer: use unary array operator ,: ,$theArray | foreach{Write-Host $_} Long answer: there is one thing you should understand about @() operator: it always interpret its content as statement, even if content is just an expression. Consider this code: $a=”A”,’B’,’C’ $b=@($a;) $c=@($b;) I add explicit end of statement mark ; here, although PowerShell allows … Read more

“Piping” output from one function to another using Python infix syntax

It is hard to implement this using the bitwise or operator because pandas.DataFrame implements it. If you don’t mind replacing | with >>, you can try this: import pandas as pd def select(df, *args): cols = [x for x in args] return df[cols] def rename(df, **kwargs): for name, value in kwargs.items(): df = df.rename(columns={‘%s’ % … Read more

How do you determine if WPF is using Hardware or Software Rendering?

Check RenderCapability.Tier Graphics Rendering Tiers RenderCapability Class [UPDATE] RenderCapability.IsPixelShaderVersionSupported – Gets a value that indicates whether the specified pixel shader version is supported. RenderCapability.IsShaderEffectSoftwareRenderingSupported – Gets a value that indicates whether the system can render bitmap effects in software. RenderCapability.Tier – Gets a value that indicates the rendering tier for the current thread. RenderCapability.TierChanged – … Read more

How to properly pickle sklearn pipeline when using custom transformer

I found a pretty straightforward solution. Assuming you are using Jupyter notebooks for training: Create a .py file where the custom transformer is defined and import it to the Jupyter notebook. This is the file custom_transformer.py from sklearn.pipeline import TransformerMixin class FilterOutBigValuesTransformer(TransformerMixin): def __init__(self): pass def fit(self, X, y=None): self.biggest_value = X.c1.max() return self def … Read more