All Questions
Tagged with lazy-evaluation python
185 questions
-1
votes
0
answers
170
views
Is there any advantage to use lazy tokenizer other than space & time efficiency?
Recently I tried to implement one tokenizer following this Python doc example for Software Design for Flexibility (SDF) exercise 5.7 (notice this is not one book teaching compiler specifically ...
4
votes
0
answers
55
views
Lazy evaluations for DataFrames
Let me provide quick demo which shows that second approach is 10x times slower than the first one.
import pandas as pd
from timeit import default_timer as timer
r = range(1,int(1e7))
df = pd....
0
votes
1
answer
22
views
petl evaluation sequence possibly causing grief
In Python's petl library, according to the documentation, "This package makes extensive use of lazy evaluation and iterators. This means, generally, that a pipeline will not actually be executed ...
0
votes
1
answer
106
views
Is Python's map function evaluation lazy?
I've been solving LeetCode's 1331. Rank Transform of an Array challenge and came up with this one-line solution:
class Solution:
def arrayRankTransform(self):
return map({e: i for i, e in ...
2
votes
2
answers
161
views
Dataframes with Common Lazy Ancestor Means Repeated Computation?
Dependency DAG
Description
Pretty straight forward, basically, I am reading some parquet files from disk using polars which are the source of data. Doing some moderately heavy duty processing (a few ...
1
vote
1
answer
125
views
Clean string column with messy data into numeric in polars
The following code has been given:
import polars as pl
import numpy as np
# Set the random seed for reproducibility
np.random.seed(0)
# Define the sample size
n = 35000000
# Define the possible ...
0
votes
0
answers
39
views
Accesing python lists inside TensorFlow graph-traceable functions
I'm trying to access a python list inside a function that can be run in eager mode or graph mode as shown below:
import tensorflow as tf
import numpy as np
class SlotGenerator:
def __init__(self):
...
1
vote
1
answer
332
views
Why does collecting a LazyFrame before joins in Polars solve my issue with index discrepancies?
Here is an example that is runnable and demonstrates the issue. Initial LazyFrame includes pairwise distances between points in a plane. Since A->B distance is equal to B->A distance I keep only ...
0
votes
0
answers
62
views
Python logging: check if a log will print before doing f-string?
Suppose I have code I want to be able to run in production or verbose mode. In verbose, I want to print debug information that will slow the program down:
import logging
import time
import sys
logging....
3
votes
1
answer
94
views
Polars timestamp synchronization lazy evaluation
I want to synchronize two numpy arrays of timestamps to each other using Polars LazyFrames.
Let's assume that I have two numpy arrays of timestamps which are stored using LazyFrames:
import polars as ...
2
votes
1
answer
395
views
Replace pivot operation for use in lazy evaluation with polars
I have a set of events at timestamps, and for each timestamp I need the sum of the "last" values of each username. This can be done with a pivot table, but I would like to use LazyFrame, ...
1
vote
0
answers
112
views
`torch.conj_physical` faster than `torch.conj` if full output is used?
conj docs
torch.conj() performs a lazy conjugation, but the actual conjugated tensor can be materialized at any time using torch.resolve_conj()
conj_physical docs
This performs the conjugate ...
0
votes
0
answers
143
views
POLARS: pycharm exited with following error code : -1073741819 (0xC0000005) while converting lazyframes to polars dataframe using lf.collect()
I have a piece of code which is performing some computations on top of lazy frames. I have the output stored in form of lazy frames in a dictionary. At the end, I am converting the outputs to pandas ...
-2
votes
2
answers
2k
views
How to do lazy instantiation in python?
in the class below variables with str type are used but without declaring value
from abc import ABC
class User(ABC):
first_name: str
last_name: str
is this lazy instantiation?
2
votes
1
answer
80
views
How to avoid parametrization of a Pytest class when skipping it?
I have two Pytest classes: one test class is very fast and the other is slower, parametrizing itself with a function call and reusing that resource across multiple tests.
My problem is that, when ...