delete
statement in a local scope PTC-W0043del
statement in a local scope428 sents = (
429 [[token.text for token in sentence] for sentence in doc] for doc in doc_sents
430 )
431 del doc_sents432
433 logger.debug("Done in %.2f seconds", time() - t0)
434 # `sents` is an array of documents where each document is an array sentences where each
del
statement in a local scope267 split_output_path = os.path.join(args.base_output_path, (name + ".json"))
268 save(dataset, split_output_path, compression=args.compression)
269
270 del dataset271 gc.collect()
272
273
del
statement in a local scope254 pool.join()
255 del source_docs_tokenized
256 del target_docs
257 del target_docs_tokenized258 gc.collect()
259
260 logger.info("Done in %.2f seconds", time() - t0)
del
statement in a local scope253 pool.close()
254 pool.join()
255 del source_docs_tokenized
256 del target_docs257 del target_docs_tokenized
258 gc.collect()
259
del
statement in a local scope252
253 pool.close()
254 pool.join()
255 del source_docs_tokenized256 del target_docs
257 del target_docs_tokenized
258 gc.collect()
Passing a local variable to a del
statement results in that variable being removed from the local namespace.
When exiting a function all local variables are deleted, so it is unnecessary to explicitly delete variables in such cases.
It is recommended to remove this del
statement.
Not preferred:
def my_func():
task = do_some_task()
evaluate_task(task)
del task # This is unnecessary.
Preferred:
def my_func():
task = do_some_task()
evaluate_task(task)